GIF Compression on Linux
Ran into oversized GIF files and needed to compress them on Linux. Two tools came up: gifsicle and ImageMagick.
gifsicle is purpose-built for GIFs, which makes it the better fit. It has three optimization levels:
- Level 1: Basic optimization, minimal file size reduction.
- Level 2: Balanced. Good compression without much speed cost.
- Level 3: Maximum compression, slowest.
Install it:
sudo apt install gifsicle
Compress with the highest optimization level:
gifsicle --optimize=3 input.gif -o compressed.gif
ImageMagick can handle GIFs too:
convert input.gif -layers Optimize compressed.gif
It works, but the results tend to be less efficient than gifsicle for GIF-specific compression.
Level 3 covers most cases well. The quality difference is barely noticeable at typical optimization levels.