# coding=gbk
import Image, ImageDraw, ImageFont
def drawSomething (fname, drawType, outpic):
img = Image.open(fname)
draw = ImageDraw.Draw(img)
width, height = img.size
if drawType == "crossline":
draw.line(((0, 0), (width-1, height-1)), fill=255)
draw.line(((0, height-1), (width-1, 0)), fill=255)
print "draw line"
elif drawType == "arc":
draw.arc((0, 0, width-1, height-1), 180, 270, fill=255)
print "draw arc"
img.save(outpic)
def drawFont (txt):
font = ImageFont.truetype("C:\\WINDOWS\\Fonts\\SIMYOU.TTF", 40)
img = Image.new("RGB", (400, 300))
draw = ImageDraw.Draw(img)
draw.ink = 0 + 255*256 + 0*255*256
#draw.text((20, 120), unicode(txt, 'gbk'), font=font)
draw.text((20, 120), txt, font=font)
img.save("text.jpg")
if __name__ == '__main__':
# img.show()
# newimg =
python-PIL显示中文
最新推荐文章于 2024-07-28 11:21:53 发布
本文介绍了如何在Python的PIL库中正确显示中文字符,首先需要确保安装了PIL模块。
摘要由CSDN通过智能技术生成