Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using imagemagick's convert to take a set of PNG's and convert to GIF. The command I am using is

convert -delay 10  -loop 0 *.png out.gif

I like the results as there is little drop in visual quality, but an issue I've run into is when my PNG's have transparent data: each frame doesn't seem to be a separate picture, but instead anywhere that was transparent you could see the previous images' data.

So for example if you have a ball rolling from left to right and the background was transparent, you would see all of the previous frames where the ball was at.

How can I deal with this? I would like the GIF to preserve the transparency if possible (otherwise, just make it a pre-defined color), but I would like a proper animation.

share|improve this question
up vote 3 down vote accepted

Check out ImageMagick's dispose option for setting how the previous frame is disposed of (or not) before the next frame is drawn.

The layer disposal method defines the way each the displayed image is to be modified after the current 'frame' of an animation has finished being displayed (after its 'delay' period), but before the next frame on an animation is to be overlaid onto the display.

   Undefined   0  No disposal specified (equivalent to 'none').
   None        1  Do not dispose, just overlay next frame image.
   Background  2  Clear the frame area with the background color.
   Previous    3  Clear to the image prior to this frames overlay.

By default, I believe it chooses "Undefined" which is equivalent to "None", which means it doesn't dispose of the previous frame.

share|improve this answer
Great! Now the previous frames don't show up. Is there a way to have it anti-aliased as well so the edges don't look too jagged? – MxyL Feb 21 '13 at 21:33
Anti-alias the frames before making the GIF would be my suggestion. Really though, that seems like a whole new question to me. :) – Ƭᴇcʜιᴇ007 Feb 21 '13 at 21:35
The individual frames are anti-aliased so I wasn't sure if it had something to do with the convert. – MxyL Feb 21 '13 at 21:38
Just keep in mind that GIF's (unlike PNGs) don't do Alpha transparency, so that's probably where the jaggies are coming from. (See here) – Ƭᴇcʜιᴇ007 Feb 21 '13 at 21:46
GIF is 256 colors indexed, and transparency is a single indexed color. It is unclear if your PNG files are 24bit or indexed color. The aliasing might be color reduction artifacts or a result of a greyscale alpha channel being converted to a single color. (above comment added as I was typing) – horatio Feb 21 '13 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .