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