IT/python 26

파이썬으로 이미지에 텍스트 새기기 2탄 - 유튜브 썸네일 만들기

위와 같은 유튜브 썸네일을 만들고 싶다. 참고로 기본 유튜브 썸네일 크기는 1280x720 px다. 포토샵이나 gimp로 해도 되지만 개인적으론 파이썬이 더 편했다. 그렇다면 아래 코드처럼 하면 된다. 여기서 stroke_width는 테두리 두께, stroke_fill은 테두리 색깔 RGB 코드다. james.jpg파일을 파이썬 파일이 있는 디렉토리에 넣고 아래 코드를 실행시키면 title.png라는 1280x720px 크기의 썸네일이 생긴다. #-*-coding: utf-8-*- from PIL import Image, ImageDraw, ImageFont im = Image.open("james.jpg") draw=ImageDraw.Draw(im) draw.text((50,235),"마! 까불지마라!..

IT/python 2021.05.12

파이썬으로 이미지에 텍스트 새기기

위 이미지에 파이썬으로 글자를 새기고 싶다. 그럼 아래와 같은 코드를 쓰면 된다. #-*-coding: utf-8-*- from PIL import Image, ImageDraw, ImageFont im = Image.open("james.jpg") draw=ImageDraw.Draw(im) draw.text((13,75),"르브론 제임스 \nLA레이커스",font=ImageFont.truetype("SCDream7.otf", 16), fill=(255,255,255)) im.save("title.png") pillow 라이브러리를 설치해야 한다. james.jpg는 원본파일이고 title.png는 글자가 세겨진 파일이다. draw.text에서 13,75는 글자가 새겨지는 위치고 그다음은 텍스트다. 한글..

IT/python 2021.04.15

파이썬에서 pandas가 설치되지 않을 때

pip -install pandas를 눌렀는데 ERROR: Could not find a version that satisfies the requirement pandas (from versions: none) ERROR: No matching distribution found for pandas 이런 에러메시지가 나오면서 pandas가 설치되지 않으면 pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org pandas 와 같은 명령어를 누르면 설치가 된다. tensorflow도 위와 같은 에러메시지가 나올 때가 있는데 그건 32비트를 깔아서 그렇다. 64비트를 깔면 제대로 된다고 한다.

IT/python 2020.06.14

좀 더 색다른 python 워드클라우드, stylecloud

import stylecloud stylecloud.gen_stylecloud(file_path="lyrics.txt", icon_name="fas fa-candy-cane", palette='cartocolors.diverging.TealRose_7') python에서 WordCloud도 있지만 좀 더 색다른 워드클라우드를 해보고 싶다면 stylecloud도 좋은 선택지입니다. 코드를 보면 매우 간단합니다. 저는 Sting의 Englishman in NewYork 가사로 워드클라우드를 만들어 봤습니다. 위 python 코드를 실행시키면 python이 설치된 폴더에 stylecloud.png라는 파일이 생깁니다. 여기서 icon은 Font Awesome 아이콘인데 https://www.joydeepdeb..

IT/python 2020.06.10