Board logo

标题: [问题求助] Python为什么图片上没有显示汉字啊 [打印本页]

作者: netdzb    时间: 2020-11-7 13:38     标题: Python为什么图片上没有显示汉字啊

我想在图片左上角显示88888888,运行结果什么都没有啊,是什么原因?
  1. import datetime
  2. import re
  3. #from PIL import Image
  4. from PIL import Image, ImageDraw, ImageFont
  5. image = Image.new(mode='RGB',size=(640, 480),color=(0,0,0))
  6. weiqi = datetime.datetime.now().strftime("%Y%m%d") + '.png'
  7. # print (datetime.datetime.now().strftime("%Y%m%d"))
  8. # print (weiqi)
  9. img=Image.open('yi001.png')
  10. width = img.size[0]
  11. height = img.size[1]
  12. print (width)
  13. print (height)
  14. img = img.resize((int(width*0.8), int(height*0.8)), Image.ANTIALIAS)
  15. image.paste(img, (120,40))
  16. draw = ImageDraw.Draw(img)
  17. font = ImageFont.truetype(font='simfang.ttf', size=10)
  18. draw.text(xy=(0,0), text='88888888', fill=(255, 255, 255), font=font)
  19. image.save(weiqi, 'png')
  20. image.close()
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2