18

How to compress GIF animations? For example by reducing the color index.

The files are generated using Imagemagick but optimization seems complicated.

For example, the following animation is 864KB at 150x119:

example animation

To be used on a Linux machine.

30

Use gifsicle (available for Mac OS X, Windows, DOS, Debian, FreeBSD and NetBSD).

gifsicle -i anim.gif -O3 --colors 256 -o anim-opt.gif

This will optimize and reduce to 256 colors, if the animation uses more colors (the example image does).

You can reduce the size by reducing the number of colors:

example image with only 256 colors 512KB, 256 colors

example image with only 128 colors 412KB, 128 colors

example image with only 64 colors 340KB, 64 colors

example image with only 32 colors 240KB, 32 colors

example image with only 16 colors 140KB, 16 colors

Based on another Q&A.

  • 1
    Thanks for your answer. It helped me a lot. I got the best result using gifsicle -i anim.gif --optimize=3 -o anim-opt.gif – Mostafa Ahangarha Nov 21 '17 at 12:50
  • works great! for some odd reason, im using a shell script that uses imagemagick and oddly it isnt working with gifs we got from videos via final cut pro (exported as image sequence) then exported thru photoshop but otherwise works on other gifs. – SMT Nov 30 '17 at 18:56
  • Available in FreeBSD ports as well: freshports.org/graphics/gifsicle – Mateusz Piotrowski Sep 16 '18 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.