标题: [问题求助] Python为什么图片上没有显示汉字啊 [打印本页]
作者: netdzb 时间: 2020-11-7 13:38 标题: Python为什么图片上没有显示汉字啊
我想在图片左上角显示88888888,运行结果什么都没有啊,是什么原因?- import datetime
- import re
- #from PIL import Image
- from PIL import Image, ImageDraw, ImageFont
- image = Image.new(mode='RGB',size=(640, 480),color=(0,0,0))
-
- weiqi = datetime.datetime.now().strftime("%Y%m%d") + '.png'
- # print (datetime.datetime.now().strftime("%Y%m%d"))
- # print (weiqi)
-
- img=Image.open('yi001.png')
- width = img.size[0]
- height = img.size[1]
- print (width)
- print (height)
- img = img.resize((int(width*0.8), int(height*0.8)), Image.ANTIALIAS)
- image.paste(img, (120,40))
-
- draw = ImageDraw.Draw(img)
-
- font = ImageFont.truetype(font='simfang.ttf', size=10)
- draw.text(xy=(0,0), text='88888888', fill=(255, 255, 255), font=font)
-
- image.save(weiqi, 'png')
- image.close()
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |