Last active
May 7, 2017 13:26
-
-
Save fy0/7c4f022a9bf9ba1690121884aaa48da5 to your computer and use it in GitHub Desktop.
PIL文本生成图片
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageFont, ImageDraw | |
text = '立行跃击' | |
font = ImageFont.truetype('../font/SourceHanSansCN-Regular.otf', 80) | |
for i in text: | |
img = Image.new('RGBA', (100, 100)) | |
brush = ImageDraw.Draw(img) | |
brush.text((10,0), i, fill='#000', font=font) | |
img.save('%s.png' % i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment