Reputation: 814
For example, I have 4 images with a size of 1000x800. I want to merge all these images into one image. I know there is a command of
convert +append image[1-4].jpg output.jpg
But I want to merge the second image into the first image by overlapping 250 pixels.
i.e., In my final image, image1 has 750 pixels as well as image2 & 3 and the last image has 1000 pixels.
By using above convert command, we will get an image size of 4000x800, but here I want it to be ((750*3)+1000*1)x800. i.e., 3250x800.
Also, how can I do this by appending vertically?
Upvotes: 0
Views: 1450
Reputation: 53081
I just tested the following in Imagemagick 6.9.9.33 Q16 Mac OSX.
Note I tested using -smush with positive values so as to see gaps and not overlaps. That was just for testing. If you follow the last command, it should work fine with negative values, if you want to overlap rather than put gaps between the images.
Create 13 images named rose0.jpg ... rose12.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "0" test/rose0.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "1" test/rose1.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "2" test/rose2.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "3" test/rose3.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "4" test/rose4.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "5" test/rose5.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "6" test/rose6.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "7" test/rose7.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "8" test/rose8.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "9" test/rose9.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "10" test/rose10.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "11" test/rose11.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "12" test/rose12.jpg
Then smush them. This fails and only appends 0-2. (I think this stucture is limited to whatever digits it sees)
convert test/rose[0-12].jpg -smush 10 test/rose_smush.jpg
This works if using only one-digit numbers.
convert test/rose[0-9].jpg -smush 10 test/rose_smush.jpg
The proper way to do this is to use the following structure.
convert test/rose%d.jpg[0-12] -smush 10 test/rose_smush.jpg
See the section of Filename Reference at http://www.imagemagick.org/script/command-line-processing.php
Upvotes: 0
Reputation: 53081
You do not say how you want to overlap them. If you do not need to blend, then in ImageMagick, you can use smush rather than append. Smush allows offsets (gaps) or overlaps. The former with positive values and the latter with negative values to overlap succeeding images. -smush appends vertically and +smush appends horizontally. The background color controls the spacing for gaps when using positive values for the argument.
So try
convert image[1-4].jpg +smush -256x0 output.jpg
or
convert image1.jpg image2.jpg image3.jpg image4.jpg +smush -256x0 output.jpg
or if those are the only images with that syntax, then
convert image*.jpg +smush -256x0 output.jpg
Upvotes: 1
Reputation: 5395
The "+smush" operator will act like "+append", but it takes an argument. A positive number will append the images separated by that many pixels. A negative number will append the images with that much overlap. Your example command would look like this...
convert image[1-4].jpg +smush -250 output.jpg
To append images vertically, use the "-smush" form of the operator. In either case the operator will align the images according to the current "-gravity" setting.
Upvotes: 2