简体   繁体   中英

AutoMerge two images files to one

I am using Montage command-line tool to merge the two jpg images. The output jpg contains the common strip present in the input jpgs. Below is the command to merge two jpgs:

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 :

在此处输入图片说明

and 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:

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. If you only have on pair of image, you can overlap them using +smush in ImageMagick. It is like +append, but allows either overlap or a gap according to the sign of the argument. Unlike -page, it only shifts in one direction according to +/- smush. Using Mark's images,

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

在此处输入图片说明

In ImageMagick, you can simply append the two images side by side or top/bottom.

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. If different sizes, then you will have background regions, which you can control the color by using -background somecolor. If desired, you can resize the images by adding -resize 500 after reading the inputs and before the append.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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