0
我想通过使用PIL来绘制文本。但我的问题是我需要运行程序后再次裁剪文本图像。我需要的只是文本,没有边界。任何人都可以建议? 谢谢。 这是我的代码:通过PIL绘制无需裁剪的文本图像
import Image, ImageDraw, ImageFont
def draw (text, size, color) :
fontPath = '/home/FreeSansBold.ttf'
font = ImageFont.truetype(fontPath, size)
size2 = font.getsize(text)
im = Image.new('RGBA', size2, (0, 0, 0, 0))
draw = ImageDraw.Draw(im)
draw.text((0, 0), text, font=font, fill=color)
im.save(text +'.png')
drawA = draw('A', 200, 'green')
drawC = draw('C', 200, 'blue')
drawG = draw('G', 200, 'yellow')
drawT = draw('T', 200, 'red')
我不明白你的问题,你能否澄清一下? – 2010-09-17 20:58:22