티스토리 뷰
공장 (factory)/- Programming..
[Python] PIL(Python Image Library) 이미지에 텍스트 넣기.
무중력인간 2020. 4. 9. 17:021. pillow 설치
python -m pip install pillow
2. 소스단
from PIL import Image, ImageDraw, ImageFont
def createImg(textData, width, height):
fontSize = 13
img = Image.new("RGB", (width, height), color = (0, 0, 0))
fnt = ImageFont.truetype("폰트 경로", fontSize, encoding="UTF-8")
# 텍스트가 시작될 X, Y 좌표
textPosition01 = 10
textPosition02 = 10
d = ImageDraw.Draw(img)
d.text((textPosition01,textPosition02), textData, font=fnt, fill=(255,255,255))
img.save("경로" + "파일명.png")
'공장 (factory) > - Programming..' 카테고리의 다른 글
| [Java] Java Stream 예제 몇 가지 (0) | 2021.08.03 |
|---|---|
| [Java] Reflection을 활용한 메서드, 필드 값 불러오기. (0) | 2021.01.22 |
| [Python] paramiko를 이용한 ssh접속 후 명령어 실행. (2) | 2020.04.09 |
| [Python] pyodbc를 이용한 MSSQL DB조회 (1) | 2020.04.09 |
| [javascript/jQuery] javascript와 jQuery 비교 정리. (0) | 2020.01.09 |
댓글