#!/usr/bin/env python
#-*- coding:utf-8 -*-
import Image, ImageFont, ImageDraw
# output string
emailString = u"こんにちは"
#get font metrics
font = ImageFont.truetype("/usr/share/fonts/truetype/takao/TakaoPGothic.ttf", 24, encoding='unicode')
size = font.getsize(emailString)
#create image
image = Image.new('RGBA', (size[0]+10, size[1]+10), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
# use a truetype font
draw.text((5, 5), emailString, font=font, fill='#000000')
#save the image
image.save("string.png", 'PNG')
でけた。
0 件のコメント:
コメントを投稿