【发布时间】:2015-12-29 19:28:47
【问题描述】:
您好,我正在尝试在图像上写入文字。但文字溢出。有什么方法可以将此类文本内容包装到图片中?
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Image(filename='/home/path/image.jpg').clone() as img:
print('width =', img.width)
print('height =', img.height)
quote = input('quote:')
with Drawing() as draw:
draw.font = 'wandtests/assets/League_Gothic.otf'
draw.fill_color=Color('red')
draw.text_alignment= 'center'
img.font_size=50
draw.text(int(img.width/2),int(img.height/2), quote)
print(draw.get_font_metrics(img,quote))
draw(img)
print('text drawn')
img.save(filename='/home/path/image01.jpg')
给定的输入是:
"Success makes so many people hate you. I wish it wasn't that way. It would be wonderful to enjoy success without seeing envy in the eyes of those around you."
【问题讨论】:
标签: python python-3.x wand magickwand