Lossy GIF compressor

This is an encoder (based on gifsicle ) which implements lossy LZW compression. It can reduce animgif file sizes by 30%—50% at a cost of some dithering/noise.

Downloads and source code on GitHub


./gifsicle -O3 --lossy=80 -o lossy-compressed.gif input.gif

Adjust --lossy argument to quality you want (30 is very light compression, 200 is heavy).

It works best when only little loss is introduced, and due to limitation of the compression algorithm very high loss levels won’t give as much gain.

How does it work

GIF’s LZW compression is based on a “dictionary” of strings of pixels seen. Normal encoder searches the dictionary for the longest string of pixels that exactly matches pixels in the image. Lossy encoder picks longest string of pixels that’s “similar enough” to pixels in the image (plus some magic to hide the distortions with dithering).


3.3MB original vs 1.2MB lossy recompression

My version (191KB)

Photoshop (201KB)

Original (438KB)

Source: Fire breathing “Jaipur Maharaja Brass Band” Chassepierre Belgium by Luc Viatour

For static GIFs don’t bother with this encoder and use lossy optimized PNG instead.

Illegal in the Apple App Store

App Store terms and conditions forbid distribution of Free Software that grants users freedom to use the program any way they want. You’re not allowed to distribute this software with DRM applied to it.

Hacker News稿源:Hacker News (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合技术 » Lossy GIF compressor

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录