How to add text on top of an image in tkinter

拥有回忆 提交于 2019-12-08 18:22:27

You need to open/load the image first... like this:

#!/usr/local/bin/python3

import numpy as np
from PIL import Image, ImageDraw, ImageFont

# Open input image
im = Image.open('image.png').convert('RGB')

# Get a drawing context
draw = ImageDraw.Draw(im)

pixellat=ImageFont.truetype("/Library/Fonts/Apple Chancery.ttf",48)
draw.text((80, 40),"This is a test",(255,255,255),font=pixellat)

# Save
im.save('result.png')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!