Page 1 of 1

Overlaying an image on multiple images

Posted: 2012-01-18T10:10:26-07:00
by Demian
ImageMagick 6.7.4-2
Windows 7
Windows command-line

I'm really new to ImageMagick but I managed to extract all frames from a GIF animation. Now I would like to overlay a gif image on top of all of these frames. I know how to compile the frames back to GIF. I can overlay individual images but not all of them at once. The frames are named f_#.gif and the overlay is overlay.gif and it is the same size as the frames. I have a bit over 200 frames.

I tried this but it only wrote one "anim_0.gif" and it was full black.

Code: Select all

composite -gravity center overlay.gif f_*.gif anim_%d.gif
This code correctly writes one image with the overlay but I don't know how I would do all of them at once.

Code: Select all

composite -gravity center overlay.gif f_0.gif anim_%d.gif
Although scaling multiple images with this code works fine.

Code: Select all

convert -scale 50% f_*.gif scaled_%d.gif

Re: Overlaying an image on multiple images

Posted: 2012-01-18T11:35:26-07:00
by glennrp
I would try the "mogrify" application with the "-draw image over ..." optoon
(first copy all of the GIF images into a new working directory and
run "mogrify" there, because the input images will be overwritten with the
watermarked ones).

Re: Overlaying an image on multiple images

Posted: 2012-01-19T06:06:30-07:00
by Demian
I can't figure out how it mogrify works. Where is the input image? This is as far as I got but it gives error not to mention there is no input image.

Code: Select all

mogrify -draw 'image Over 0,0 0,0 "overlay.gif"' anim_%d.gif

Re: Overlaying an image on multiple images

Posted: 2012-01-19T10:08:19-07:00
by fmw42

Re: Overlaying an image on multiple images

Posted: 2012-01-19T10:24:42-07:00
by Bonzo
Try this

Code: Select all

convert animation.gif -coalesce -gravity South -geometry +0+0 null: watermark.png -layers composite -layers optimize watermarked_animation.gif
Refresh this page to see the example again.
Image

Re: Overlaying an image on multiple images

Posted: 2012-01-19T10:32:53-07:00
by Demian
Bonzo wrote:Try this

Code: Select all

convert animation.gif -coalesce -gravity South -geometry +0+0 null: watermark.png -layers composite -layers optimize watermarked_animation.gif
Oh my. That worked. Thanks!

Any idea how to make individual frames longer in a gif? For example frame 1 would be 2 seconds long, frames 2-100 4ms and frame 101 10 seconds?

Re: Overlaying an image on multiple images

Posted: 2012-01-20T03:22:35-07:00
by anthony
You can also use -layers composite to overlay one image over a large number of images already in memory.

EG:
convert logo: granite: null: rose: -geometry +10+10 -layers composite images_%d.png

This overlays the rose image onto two images.

See IM Examples...
http://www.imagemagick.org/Usage/anim_mods/#composite
and specifically the next section on the operators special handling when only one image is provided in one of the two image lists (separated by the special "null:" marker image)