AutoMerge将两个图像文件合并为一个

时间:2017-07-14 06:37:09

标签: cmd imagemagick montage imagemagick-montage

我使用蒙太奇命令行工具合并两个jpg图像。输出jpg包含输入jpgs中的公共条带。下面是合并两个jpgs的命令:

montage -geometry 500 input1.jpg input2.jpg output.jpg

如何避免输出文件中的公共区域? 还有其他工具可用于自动合并这两个图像吗?

3 个答案:

答案 0 :(得分:1)

我怀疑你是想通过拼接两个共同重叠区域的图像来制作全景。

所以,如果我们从left.png开始:

enter image description here

right.png

enter image description here

你可能想要这个:

convert left.png -page +200 right.png -mosaic result.png

enter image description here

这样您就可以看到如果我更改x偏移量以及如何添加y偏移量会发生什么:

convert left.png -page +280+30 right.png -mosaic result.png

enter image description here

答案 1 :(得分:1)

如果你想做Mark Setchell所建议的,那么使用-page可能是最好的方法,如果要合并多个图像并且偏移量不同。如果你只有一对图像,你可以在ImageMagick中使用+ smush重叠它们。它类似于+ append,但根据参数的符号允许重叠或间隙。与-page不同,它只根据+/- smush在一个方向上移动。使用Mark的图片,

convert left.jpg right.jpg +smush -400 result.jpg

enter image description here

答案 2 :(得分:0)

在ImageMagick中,您可以简单地将两个图像并排或顶部/底部附加。

convert image1.jpg image2.jpg -append result.jpg

将做顶部/底部

convert image1.jpg image2.jpg +append result.jpg

将左/右。

您可以根据需要添加不同尺寸的图像。您可以使用-gravity设置根据需要对齐它们。如果尺寸不同,那么您将拥有背景区域,您可以使用-background somecolor控制颜色。如果需要,您可以在读取输入之后和追加之前添加-resize 500来调整图像大小。

请参阅http://www.imagemagick.org/Usage/layers/#append

相关问题