
Highest-quality GIF encoder based on pngquant - modinfo
https://gif.ski
======
pornel
Author here: yes, please use 21st century codecs whenever you can.

This is intended only for interoperability. There are sites/apps that take
"GIF" too literally and don't allow uploads of efficient formats. If you need
to share a GIF now you can waste bandwidth at least without ruining the
quality.

I wrote this only because most encoders make GIFs look _awful_ , as if nobody
upgraded the encoders since '90s. This one uses pngquant, which takes
quantization very seriously. Plus it guides pngquant to put more weight on
pixels seen longer on screen, avoids creating redundant colors which can be
reused from previous frames, and does dithering across frames, which "patches"
previous frames as neatly as possible. Overall it gives anims with 1000-3000
colors per frame.

It's written in Rust and does decode/convert/encode in parallel, because it
was fun to do.

If you want smaller GIFs, I also wrote another compressor with opposite
quality/size trade-off:
[https://kornel.ski/lossygif](https://kornel.ski/lossygif) (or use WebM!)

~~~
aw3c2
Very cool projects indeed!

------
ronjouch
gifski is awesome and, be careful, produces big GIFs.

Linux users, it's available in peek, a very usable GNOME-ish screencasting
tool.
[https://github.com/phw/peek/issues/212](https://github.com/phw/peek/issues/212)

~~~
nolok
What would be the use case of this versus WebM ?

~~~
ronjouch
_For me_ , due to GitHub/BitBucket restrictions. When spitting a piece of
frontend code, I like to help my fellow reviewing collea^H^H^H^H^Hvictims with
a little screencast of what my code ends up looking like, typically ten
seconds of me clicking around the new feature.

GitHub/BitBucket (as of today) won't let me embed a webm/mp4 to a comment
field in a Pull Request, but supports drag&dropping a GIF and displaying it
inline, so GIF it is for now ¯\\_(ツ)_/¯. Maybe our GitHub & Atlassian
overlords will see the light at some point in the future, hopefully before the
end of our year 1998. I see _one_ intrinsic valuable feature in GIF today: the
guarantee that there will be no sound (and even this is kinda moot, an
mp4/webm video can be embedded muted by default). Other than that, I agree,
it's a shame not to use a better format.

------
aw3c2
With WebM I see no reason to use actual GIF anymore. It is such a waste of
bandwidth and processing power.

~~~
onion2k
You should absolutely use WebM as an enhancement, but the support for it isn't
good enough to drop GIF entirely yet.
[https://caniuse.com/#feat=webm](https://caniuse.com/#feat=webm)

~~~
kalleboo
mp4 has universal support though (Except for Opera Mini, which doesn't support
animated GIFs either)
[https://caniuse.com/#search=mp4](https://caniuse.com/#search=mp4)

------
leeoniya
> fancy features for efficient cross-frame palettes and temporal dithering

(shameless plug) RgbQuant [1] does the former, too :)

[1]
[https://github.com/leeoniya/RgbQuant.js](https://github.com/leeoniya/RgbQuant.js)

------
ttoinou
How does it compare to ffmpeg gif encoder ? Can it be used to compress well
gif too ?

How can it support thousands of colors, I thought GIF was limited to a 256
colors palette ?

~~~
pornel
The quality is much higher than ffmpeg. Encoding is slower.

GIF works like a canvas that can be painted on with 256 colors at a time. This
encoder takes care to reuse existing colors on the canvas as efficiently as
possible.

Also most encoders generate ugly palettes (e.g. for a start throwing out 3 of
8 bits of precision) and use naive dithering.

This one spends so much effort on getting optimial palettes, that if I were to
get VC funding for it, I'd say it does machine learning.

~~~
ttoinou

      This one spends so much effort on getting optimial palettes, that if I were to get VC funding for it, I'd say it does machine learning. 
    

Lol

Maybe we could turn this into a product together. Videographers like making
GIFs.

------
frik
Great image quality!

Definitely better a lot than ffmpeg with palette option. (are there other gif
tools, how do they compare?)

GIF format may be really dated, but it's really light on resources.

I learned the hard way that playing dozens of small short MP4 video clips on a
web page will chock your (mobile) browser, but displaying the same clips as
GIF is no problem at all.

Edit: I wrote "dozens of clips", if you don't believe me, try it out yourself,
and no video codecs like MP4 are more hardware intensive if your
smartphone/tablet graphic card has to render more than a few.

~~~
ttoinou
And color accuracy seems better with GIF also

~~~
cooper12
Uhh, GIF only supports 256 colors per frame. I'm not sure what you mean.
"Accuracy" of color is more affected by monitor calibration than the actual
format (ignoring embedded color profiles used by photographers).

~~~
ttoinou
I don't know about WebM VP9 but with H264 colors are often in the 16 - 235
range. I can spot in a webpage when it's a video and not a GIF because colors
are washed out and can't be as saturated as with GIF

~~~
pornel
"Washed out" is not a fault of H.264 per se, but video decoders being awful at
color management. Most common errors are lack of gamma correction for Rec 709
and assuming that less-than-HD videos are in ill-defined BT 601 color space.

There's also a lesser problem of chroma subsampling destroying fine saturated
details. WebM/VP9 supports full-res chroma.

~~~
ttoinou
I agree but the fact stay the same : you put a H264 video and a GIF in a
webpage, most of the time you get better colors with the GIF.

(H264 also has 444 by the way)

