python生成单个文字图片素材(白底黑字)

#!/usr/bin/env python
# coding=utf-8

from PIL import Image, ImageDraw, ImageFont

#image = Image.new(mode='RGBA', size=(50, 50),)

image = Image.new("RGB",(50,50),"white")
draw_table = ImageDraw.Draw(im=image)
draw_table.text(xy=(0, 0), text=u'仰', fill='#000000', font=ImageFont.truetype('./SimHei.ttf', 50))

image.show()  # 直接显示图片
image.save('满月.png', 'PNG')  # 保存在当前路径下,格式为PNG
image.close()
其中SimHei字体文件我上传到了百度云,链接:https://pan.baidu.com/s/1QhSMUuQurZ18wVgVk4p_-g 密码:g0n4

你可能感兴趣的:(python生成单个文字图片素材(白底黑字))