python中使用pillow绘制汉字

# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow

from PIL import Image, ImageFont, ImageDraw

# 微软雅黑的字体
path_to_ttf = r'c:\windows\fonts\msyh.ttc'
font = ImageFont.truetype(path_to_ttf, size=100)

# 打开指定文件
img=Image.open(r"D:\少儿编程\Python\ShowImage\bin\Debug\学生\蔡昊.jpg")
# 写文字
draw = ImageDraw.Draw(img)
draw.text(xy=(100, 300), text='Hello,南墙已破!', font=font,fill=(255,0,0,255))
# 输出
img.show()

 

posted @ 2018-05-21 13:42  糖豆爸爸  阅读(1015)  评论(0编辑  收藏  举报
Live2D