我把两张图片粘在一起,把它们放在一个框架中( template_image是框架),加上一些文本(标题和艺术家的名字)。用药剂做的。
(append).
我的问题是如何将文本定位在新合成的图像上。我使用
"-gravity",
"SouthWest", # this doesn't position bottom left若要放置文本位置,请执行以下操作。然而,它附着在第一张图片的底部.不是到新合成的图像的底部。就好像它没有看到新图像的大小。
如何正确设置位置,使文本出现在左下角。谢谢。
[
"#{original_file_path}[0]",
"-resize",
"500x500",
"#{original_file_path2}[0]",
"-resize",
"500x500",
"-append",
"-background",
"Black",
"-gravity",
"center",
"-extent",
size,
template_image.path,
"-gravity",
"center",
"-composite", # new image created
"-gravity",
"SouthWest", # this doesn't position bottom left
"-fill",
"white",
"-font",
"arial",
"-pointsize",
"22",
"-annotate",
"+10+40",
title,
"-fill",
"white",
"-font",
"arial",
"-pointsize",
"12",
"-annotate",
"+10+20",
artist_name,
"-quality",
"85",
destination_path
]
end

发布于 2021-03-04 11:59:22
根据Mark的评论,在-composite之后立即添加+重新页面。啊,真灵。我不能为这件事承担责任-谢谢你马克·塞切尔。
医生们说:
使用+重新页面完全删除/重置图像中的虚拟画布元数据。
因此,etc似乎重置了与图像大小和定位等有关的元数据,因此imagemagick有正确的信息来执行下一次操作等。
https://stackoverflow.com/questions/66071561
复制相似问题