Lossy GIF compressor

综合技术 2018-03-13

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.


21 technologies transforming software development A long time ago, developers wrote assembly code that ran fast and light. On good days, they had enough money in their budget to hire someone to toggle...
This Post is Meaningless – the Liar Paradox The Liar Paradox is simple enough to explain – is the following statement true or false? This statement is false. If it’s true then it’s false, bu...
Constraints and Creativity Mihaly Csikszentmihalyi is famous for defining and disseminating the idea of ‘flow.’ But some of his less famous work involves the study of creativity...
Monster Farm 开发日志 (六)基于MarkovChain的随机名字生成器... 光阴似箭,日月如梭,又到了我写DevBlog的时辰了。由于周更平常又忙,zed上周就在挣扎不知道该写啥,还羡慕我说我这周可以写写GDC的见闻,我就嗯了一声。但实际上,作为一个有料的男人,我是不虚的,所以GDC见闻留给他,这次我要跟大家说我们怪物的随机名字生成器。 由于我是个简单的...
完成一个H.265/HEVC码流分析工具 经过大约一个月左右的业余时间,终于初步完成一个H.265/HEVC码流分析工具。时间包括平时的周末、晚上,以及调休的集中时间。当然,中秋回家过节不写代码。截至今天,经过多种H.265序列测试,也有各种工具对比,基本上无大问题,v2.0版本终于释放出来。v1.x版本是去年年初做的,弹指间一年多的今天...
Hacker News

责编内容来自:Hacker News (本文源链)
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。