Page 1 of 1

adjoining animated gif produces frames of changed data...

Posted: 2007-04-03T10:58:18-07:00
by jpeterson
Greetings..

I am writing a function that overlays one animated gif onto another.

Currently I loop through both animated gifs and create frames using +adjoin... and then blend the frames together .. (repeating the one with fewer frames if applicable)

What I am finding is that the animated gif frames contain only the graphical data that has changed from the previous frame. So all of the information is in the 000_whatever.gif file and 001_whatever.gif contains mostly transparent background and just image where it has changed.

The way I have tried to fix this is after I have created the frames.. I loop through the frames again and place a copy of the first frame in the background. The problem with this is that the image border is reduced to only be the size of the changed image and I can't line them up.


So.. for example:

When I programatically place this:

Image

On top of this:
Image


I get:
Image


so..

1. - Is there a way to get all of the animated gif frame information (not just the changed information)

--if not then --

2. - Is there a wayto force the borders and size when initially creating the idividual frames to maintain their location in relation to the first frame?



Any help would be greatly appreciated.

Re: adjoining animated gif produces frames of changed data...

Posted: 2007-04-03T19:56:18-07:00
by anthony
jpeterson wrote: What I am finding is that the animated gif frames contain only the graphical data that has changed from the previous frame. So all of the information is in the 000_whatever.gif file and 001_whatever.gif contains mostly transparent background and just image where it has changed.


That is typical for a animation that has Transparency Optimization added to attempt to improve the overall compression ratio of the GIF.
See IM Examples on GIF animation Optimization...
http://www.imagemagick.org/Usage/anim_opt/#opt_trans

The fix is to use -coalesce to convert a animation using GIF disposals to a film-like coalesced animation. That is simplfy it by doing all the overlays as you describe.
See http://www.imagemagick.org/Usage/anim_basics/#coalesce

This should fix all those problems. You may also like to look at the other IM example pages for other GIF handling tecniques. Also more 'layer' functions are appearing.

For example the very latest IM can actually impliment transparency optimization, and as of last monday the beta has a 'RemoveDups' to merge consective duplicate images from a coalesced animation (merging delay times as appropriate). In the next day or so a 'RemoveZero' method will also net to remove 'zero time delay' frames, which is another typical optimization tecnique, explained in IM examples.

PS: also look at a new 'ChangeMask' composition function that lets to extract the changed pixels from one image to another.

Re: adjoining animated gif produces frames of changed data...

Posted: 2007-04-06T08:13:42-07:00
by jpeterson
anthony wrote: The fix is to use -coalesce to convert a animation using GIF disposals to a film-like coalesced animation. That is simplfy it by doing all the overlays as you describe.
See http://www.imagemagick.org/Usage/anim_basics/#coalesce


Beautiful. Works like a charm. Many thanks.

You see what happens when noobies try to play around with this stuff??

Re: adjoining animated gif produces frames of changed data...

Posted: 2007-04-07T04:59:43-07:00
by anthony
That is what IM Examples is for... to give you 'noobies' a place to study how to do something and become expert in using ImageMagick.

If you figure out something interesting though, for find a solution to a problem not seen in IM examples, please be sure to contribute back. Some of the best advanced sections were created because of people like you (see the 'video' section for a case in point).