我已阅读主题“ App Engine、PIL 和覆盖文本”。
下面的代码将显示损坏的图像,我应该如何纠正?
class TestImg(webapp2.RequestHandler):
def get(self):
text_img = Image.new('RGBA', (800,600), (0, 0, 0, 0))
draw = ImageDraw.Draw(text_img)
draw.text((0, 0), 'HELLO TEXT', font=ImageFont.load_default())
self.response.headers['Content-Type'] = "image/png"
self.response.write(draw)