imagemagick composite multiple images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
ifkey
Posts: 11
Joined: 2018-08-23T11:50:07-07:00
Authentication code: 1152

imagemagick composite multiple images

Post by ifkey »

Hello
I have a lot of files in my folder 1,2,3,4,5,6,7 .... PNG and 1,2,3,4,5,6,7 .... tiff and I need to merge them

Code: Select all

composite * .png * .tif *.png
does not work
ImageMagick 7.0.8-49 Q8 x64

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: imagemagick composite multiple images

Post by snibgo »

What is your platform (Windows, bash, etc?). How large are your inputs?

If the inputs are small enough to fit into memory at the same time, you could use "-layers composite", like this:

Code: Select all

magick *.tif NULL: *.png -layers Composite out_%d.png
Otherwise, you could write a shell loop, so the magick command in the loop operated on only a single pair of files.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagemagick composite multiple images

Post by fmw42 »

Can you explain more about how you want to merge them? Are you trying to overlay the PNG on the TIFF or put them side by side? Are the images the same size? Do they have transparency? Perhaps post and example input pair and your desired output image.

You cannot use wild cards in ImageMagick commands that way as both input and output. Even if you could, wild cards should not have spaces after the *.

If you are overlaying them you can use -layers composite as described for animation merging. See https://imagemagick.org/Usage/anim_mods/#merging

Code: Select all

magick *.tiff null: *.png -layers composite result.png
should work and created result-0.png, result-1.png ...

Locked