您可以改用此命令:
convert background.jpg foreground.jpg -gravity SouthEast -compose Src_Over -composite output.jpg
所以如果这是我们的背景:

这是我们的前景:

我们得到以下结果:

实际上,我认为他在图像的另一侧看起来更好,但仍然脸向内:-)
convert background.jpg \( tiger.png -flop \) -gravity SouthWest -compose Src_Over -composite out.jpg

更新的答案
很遗憾听到该命令在内部不起作用typo3
。这里有另一个版本可能对你有用......
首先获取背景和前景图像的宽度和高度 - 我想有一种方法可以做到这一点typo3
,但我会这样做:
identify -format "%w %h" background.jpg
906 603
所以背景是 906 px 宽和 603 px 高,并且
identify -format "%w %h" tiger.png
258 296
老虎是 258 x 296 像素。然后我们可以geometry
像这样叠加使用,通过从背景的宽度和高度中减去老虎的宽度和高度,得到从图像左上角的偏移量:
convert background.jpg tiger.png -geometry +648+307 -composite out.png
这给出了与 相同的效果gravity southeast
。也许这会让你到达那里......
上次更新了一个
这个必须让你到达那里......只需在原始draw
命令中放置正确的偏移量,而不是依赖gravity
. 所以前两个数字是叠加图像左上角与背景图像左上角的 x,y 偏移量,第二个 x,y 对是叠加图像右下角的偏移量。所以基本上,
x1,y1 = width background - width overlay, height background - height overlay
x2,y2 = width background, height background
convert background.jpg -draw 'image Over 648,307 906,603 tiger.png' out.jpg