2011-11-13 2 views

답변

1

먼저 (pip install Pillow)

참고 파이썬 이미징 라이브러리를 설치 : 당신이 당신의 글꼴 파일 font_fname의 경로를 변경해야 할 수도 있습니다.

import scipy as sp 
import PIL 
import PIL.Image as Image 
import PIL.ImageDraw as ImageDraw 
import PIL.ImageFont as ImageFont 

font_fname = '/usr/share/fonts/truetype/freefont/FreeSansBold.ttf' 
font_size = 200 
font = ImageFont.truetype(font_fname, font_size) 

h, w = 1080, 1920 
bg_colour = (255, 255, 255) 
bg_image = sp.dot(sp.ones((h,w,3), dtype='uint8'), sp.diag(sp.asarray((bg_colour), dtype='uint8'))) 
image0 = Image.fromarray(bg_image) 
draw = ImageDraw.Draw(image0) 
draw.text((530, 160), "hello world", font=font, fill='rgb(0, 0, 0)') 
image0.save('hello_world.jpg') 
+0

특수 효과 (예 : 그림자, 확장, 노이즈 등)를 추가하는 방법은 무엇입니까? – NightFury13