Skip to content

Instantly share code, notes, and snippets.

@fy0
Last active May 7, 2017 13:26
Show Gist options
  • Save fy0/7c4f022a9bf9ba1690121884aaa48da5 to your computer and use it in GitHub Desktop.
Save fy0/7c4f022a9bf9ba1690121884aaa48da5 to your computer and use it in GitHub Desktop.
PIL文本生成图片
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