首页
社区
课程
招聘
未解决 [求助]为什么图片上没有显示汉字啊
发表于: 2020-11-7 13:22 1275

未解决 [求助]为什么图片上没有显示汉字啊

2020-11-7 13:22
1275
我想在图片左上角显示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()


[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//