简体   繁体   English

自动将两个图像文件合并为一个

[英]AutoMerge two images files to one

I am using Montage command-line tool to merge the two jpg images. 我正在使用Montage命令行工具来合并两个jpg图像。 The output jpg contains the common strip present in the input jpgs. 输出jpg包含输入jpg中存在的通用条。 Below is the command to merge two jpgs: 以下是合并两个jpg的命令:

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

How can I avoid the common area in the output file? 如何避免输出文件中的公用区域? Is there any other tool available to auto-merge the two images? 是否有其他工具可以自动合并两个图像?

I suspect you are trying to make a panoramic by stitching two images with an area of common overlap. 我怀疑您是通过将两幅具有共同重叠区域的图像拼接在一起来进行全景拍摄。

So, if we start with left.png : 因此,如果我们从left.png开始:

在此处输入图片说明

and right.png : right.png

在此处输入图片说明

You probably want this: 您可能想要这样:

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

在此处输入图片说明


Just so you can see what happens if I change the x-offset and also how to add a y-offset: 就像这样,您可以看到如果更改x偏移会发生什么,以及如何添加y偏移:

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

在此处输入图片说明

If you want to do what Mark Setchell is suggesting, then using -page is probably the best method, if you have more than one image to merge and the offsets are different. 如果要执行Mark Setchell的建议,则如果要合并多个图像且偏移量不同,则使用-page可能是最好的方法。 If you only have on pair of image, you can overlap them using +smush in ImageMagick. 如果只有一对图像,则可以使用ImageMagick中的+ smush重叠它们。 It is like +append, but allows either overlap or a gap according to the sign of the argument. 就像+ append一样,但是根据参数的符号允许重叠或间隔。 Unlike -page, it only shifts in one direction according to +/- smush. 与-page不同,它仅根据+/-涂抹向一个方向移动。 Using Mark's images, 使用Mark的图像,

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

在此处输入图片说明

In ImageMagick, you can simply append the two images side by side or top/bottom. 在ImageMagick中,您可以简单地将两个图像并排或顶部/底部附加。

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

will do top/bottom 将做顶部/底部

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

will do left/right. 将做左/右。

You can append as many images as you want of different sizes. 您可以根据需要添加任意数量的不同大小的图像。 You can use the -gravity setting to align them as desired. 您可以使用-gravity设置根据需要对齐它们。 If different sizes, then you will have background regions, which you can control the color by using -background somecolor. 如果大小不同,则将具有背景区域,您可以使用-background somecolor来控制颜色。 If desired, you can resize the images by adding -resize 500 after reading the inputs and before the append. 如果需要,可以在读取输入之后和追加之前添加-resize 500来调整图像的大小。

See http://www.imagemagick.org/Usage/layers/#append 参见http://www.imagemagick.org/Usage/layers/#append

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM