Elixir Imagemagick 重力偏移
Elixir Imagemagick gravity offset
我将两张图片粘在一起,将它们放在一个框架中(template_image 是框架),并带有一些文本(标题和艺术家姓名)。在 Elixir 中实现。
- 合并图像,使它们堆叠在其他作品之上(附加)。
- 合成图像和帧图像也可以。
我的问题是在新合成的图像上定位文本。我用
"-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
根据 Mark Setchell 的评论,在 -composite 之后立即添加了 +repage。有效。这不能归功于我 - 谢谢 Mark Setchell。
文档说:
Use +repage to completely remove/reset the virtual canvas meta-data
from the images.
因此 Repage 似乎重置了与图像大小和定位等相关的元数据 - 因此 imagemagick 具有执行下一个操作等的正确信息。
我将两张图片粘在一起,将它们放在一个框架中(template_image 是框架),并带有一些文本(标题和艺术家姓名)。在 Elixir 中实现。
- 合并图像,使它们堆叠在其他作品之上(附加)。
- 合成图像和帧图像也可以。
我的问题是在新合成的图像上定位文本。我用
"-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
根据 Mark Setchell 的评论,在 -composite 之后立即添加了 +repage。有效。这不能归功于我 - 谢谢 Mark Setchell。
文档说:
Use +repage to completely remove/reset the virtual canvas meta-data from the images.
因此 Repage 似乎重置了与图像大小和定位等相关的元数据 - 因此 imagemagick 具有执行下一个操作等的正确信息。