srinivasv wrote:I have a slightly different problem, I would like to append the first image in Folder A with the first image in Folder B. Append the 2nd image in Folder A with the 2nd image in Folder B and repeat the process for all files. Both folders have the same number of images and are of the same size and resolution. I would like the output to be saved in Folder C.
I'm using ImageMagick 6.9.3-9 on Windows 7 64, so I haven't tested it on *nix shell, but something like this should get you going in the right direction...
Code: Select all
convert \
FolderA/*.png \
-gravity north \
-extent 100%x200% \
null: \
FolderB/*.png \
-gravity south \
-layers composite \
-scene 1 \
FolderC/merged%04d.png
That will bring all the PNG images from FolderA into a stack.
It sets the gravity to "north" and increases the canvas size of those FolderA images to 200% of the height by adding more canvas to the bottom of each.
Then it calls in the "null:" image to separate the stack you just created from the next stack coming up. <-- Very important.
Then it will bring in all the PNG images from FolderB.
Next it sets the gravity to "south" so the composite operation places the FolderB images on the lower half of the now extended FolderA images.
The "-layers composite" operation alternately takes the images from FolderA and FolderB stacks, compositing each FolderB image onto the bottom half of its companion FolderA image. That's what the "null:" between the two stacks of images does.
It finishes by putting all the output images in FolderC, numbered to 4 places, starting at 1 with "-scene 1", and with filenames like "merged0001.png", "merged0002.png", ... "merged9999.png".
You may have to swap the gravity north/south if you want the FolderB image on top.
You can even change it to east/west if you want them appended side by side instead of over/under. You'll need to change the extent operation to "-extent 200%x100%" to double the width instead of height of the canvas if you make them go side by side.