Python为图像添加文本内容(Writing Text on Image)
Posted Data+Science+Insight
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python为图像添加文本内容(Writing Text on Image)相关的知识,希望对你有一定的参考价值。
Python为图像添加文本内容(Writing Text on Image)
#原始图像
#图像添加文本
#
from PIL import Image, ImageDraw, ImageFont
img = Image.open("E:\\\\R_Scripts\\\\cox\\\\sex.png")
d1 = ImageDraw.Draw(img)
# myFont = ImageFont.truetype(\'E:/PythonPillow/Fonts/FreeMono.ttf\', 40)
# d1.text((0, 0), "Sample text", font=myFont, fill =(255, 0, 0))
d1.text((1000, 1000), "this is our work result png", fill =(255, 0, 0))
img.show()
img.save("E:\\\\R_Scripts\\\\cox\\\\sex_text.png")
#
from PIL import Image, ImageDraw
img = Image.open(test.jpg\')
d1 = ImageDraw.Draw(img)
d1.text((28
以上是关于Python为图像添加文本内容(Writing Text on Image)的主要内容,如果未能解决你的问题,请参考以下文章
“Can't open file for writing”或“operation not permitted”的解决办法
linux操作提示:“Can't open file for writing”或“operation not permitted”的解决办法
linux操作提示:“Can't open file for writing”或“operation not permitted”的解决办法