Overlay multiple animated gifs on jpeg (converted to gif)

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?".
Post Reply
fommes

Overlay multiple animated gifs on jpeg (converted to gif)

Post 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!
fommes

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

Post by fommes »

No one, Anyone ? :(
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fommes

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

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

WIth IM you can so it all in one command without needing to save out temporary images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fommes

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

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fommes

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

Post 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!
Post Reply