使用 Python 我希望能够使用 PIL 以不同角度绘制文本。
例如,假设您正在钟面周围绘制数字。号码3会按预期出现,而12我们将逆时针旋转 90 度来绘制。
因此,我需要能够从许多不同的角度绘制许多不同的弦。
将文本绘制到临时空白图像中,旋转该图像,然后将其粘贴到原始图像上。您可以将这些步骤包装在一个函数中。祝你好运,找出要使用的确切坐标——我冰冷的大脑现在还不能胜任。
该演示在图像上倾斜书写黄色文本:
# Demo to add rotated text to an image using PIL
import Image
import ImageFont, ImageDraw, ImageOps
im=Image.open("stormy100.jpg")
f = ImageFont.load_default()
txt=Image.new('L', (500,50))
d = ImageDraw.Draw(txt)
d.text( (0, 0), "Someplace Near Boulder", font=f, fill=255)
w=txt.rotate(17.5, expand=1)
im.paste( ImageOps.colorize(w, (0,0,0), (255,255,84)), (242,60), w)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)