mattdesl / gifenc

fast GIF encoding
MIT License
301 stars 20 forks source link

PnnQuant dither #9

Open 3400442579 opened 3 years ago

3400442579 commented 3 years ago

https://github.com/mcychan/PnnQuant.js

mcychan commented 2 years ago

gifenc cannot handle alpha channel using option "rgba4444", apng could not convert to animated gif. Original: clock Result: test

mcychan commented 2 years ago

gifenc offers no dithering. Original: dg Result: test2

mattdesl commented 2 years ago

I'm not sure if these are issues or just statements about Pnnquant?

gifenc should already support transparency. If you wish to add dithering you can do so with something like floyd-steinberg module before writing the frame.

marcofugaro commented 2 years ago

@mattdesl any more details on how to add dithering? currently if you record anything else than flat 2D graphics the banding is very noticeable

mattdesl commented 2 years ago

There’s a variety of modules for dithering on npm. A popular technique is Floyd Steinberg- you can see it in action with gifenc here, feel free to use this code:

https://github.com/mattdesl/artblocks-renderer/blob/24b3c64fd8472d003d5547723f2ff9f528fc4378/src/recording.js#L156

(also see dither.js in that repo)