SkyWalker
SkyWalker

Reputation: 14327

Imagemagick: How to reduce size for annimated GIF with big static areas?

I created an animated output.gif from a screen capture that ends up being 89MB uncompressed. Half of the GIF is static but it would be best keeping it together rather than an image + a GIF containing the moving part.

Using Imagemagick and the following command I manage to reduce its size down to 18.1MB:

convert output.gif -coalesce -fuzz 3% +dither -layers Optimize compressed.gif

Increasing the percent produces much smaller size results but the quality is compromised.

Is there an option you suggest using for yielding a much better file size reduction without compromising on quality given that this GIF contains a large static non animated area?

UPDATE I'm using Ubuntu for this and here is my full workflow:

  1. Use Kazam to screen capture exactly what I need so no need for editing of any kind.
  2. Use the command ffmpeg -i input.avi output.mp4 to convert to mp4.
  3. Make directory for the frames mkdir frames.
  4. Generate intermediary images ffmpeg -i output.mp4 -r 25 'frames/frame-%04d.png'.
  5. Go to frames cd frames.
  6. Generate the GIF from the images convert -delay 4 -loop 0 *.png output.gif.
  7. Optimize and compress the GIF to reduce file size convert output.gif -coalesce -fuzz 3% +dither -layers Optimize compressed.gif

Upvotes: 3

Views: 4778

Answers (1)

xenoid
xenoid

Reputation: 8994

The best way to reduce the size of the GIF is to put as many frames as possible in "combine" mode. These frames only contain what has changed from the previous frame and this can be quite small, but this may require that all the frames be encoded with the very same colormap, and that identical parts are truly identical (no fuzziness, no random encoding artifacts). Gimp can do that but other utilities specialized in GIF processing can also do that (Gifsicle perhaps)?

Also, the animated GIF of a screen capture doesn't need to be 25fps, 10fps is more than enough.

Upvotes: 3

Related Questions