Page 1 of 1

Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-09T08:52:32-07:00
by fommes
Hi there, I would like some help with the following situation:

I have been trying and googling for 2 days now but cant seem to find the correct way to make this work.

I have made an upload form where people can upload their foto's these are getting converted to gif 256 colors, now what i would like to do is overlay a few animated gifs over this uploaded picture, i got it to work with 1 animated gif like this:

Code: Select all

exec('/usr/bin/convert logo2.gif  -repage 640x480+140+80\! -coalesce \
              -draw \'image DstOver 0,0 0,0 "fotoblings/25010903200811411205059282.gif"\' \
          -layers Optimize   overlay_images/testje.gif');
If i am not mistaking what happens here is: i set the logo2.gif (this is the actual overlay but couldnt get it animated with srcover for some reason.) as the main image with the width and height of the picture.
Then i put the picture that someone uploads at the back of the transparent logo2.gif.

The problem is, if i do this multiple times with different locations of the logo2.gif the newest logo2.gif will be animated but the ones that i put in before will be stills.

My question is, how can i get multiple "Animated gifs" to overlay a picture(gif)

I will make sure all the gifs have the same framecount etc.

Thanks in advance!

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-10T03:43:39-07:00
by fommes
No one, Anyone ? :(

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-14T04:18:24-07:00
by anthony
You must remember that to IM a animation is a whole series of images.

The -draw overlay method is not designed with a series of images in mind. However newer IM's have a -layers Composite whcih is designed to overlay a series of images, such as an animation.

See IM Examples, Animation Modifications,
Multi-Image Alpha Composition
http://imagemagick.org/Usage/anim_mods/#compose

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-14T04:27:51-07:00
by fommes
thanks for the reply, i managed to do it totally different now,

- with imagemagick i split the animated gif into seperate frames
- with GD i overlay each frame on the background (so an animation has 6 frames i merge the background with a seperate frame 6 times)
- then i merge al the frames together into one animated gif

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-15T01:40:45-07:00
by anthony
WIth IM you can so it all in one command without needing to save out temporary images.

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-15T07:12:44-07:00
by fommes
That would be great, could you give me an example?

Also at the moment i use gd to rotate a gif image (imagerotate) the problem is i can only rotate transparent gifs at angle increments of 90 degrees, because else it will lose some of the transparency.

Is there a imagemagick alternative that keeps the transpareny at all angles?

With regards,

Thomas.

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-15T19:55:57-07:00
by anthony
See previous link. The first example at that link location is using -draw. After that the -layer composite is exampled, finishing with a easier method of doing exactly what you are trying to do.

Gravity and geometry offsets are also handled by that operator.

As for animation rotation...
-background none -rotate {angle}
will rotate a 'coalesced' animation, keeping the transparency, however like resizing images the rotated images will have new colors, and include semi-transparent pixels that may need to be looked at for a specific animation. Without transparency you should have less problems.

Re: Overlay multiple animated gifs on jpeg (converted to gif)

Posted: 2008-03-16T05:08:12-07:00
by fommes
Thanks for all the advice, I will have a look at the link this week, when I understand it and made it work I'll let you know!