how to get color palette
forresto opened this issue · comments
Is it true that we have to define and pass a color palette with each frame? Is there any chance that we could use something like https://github.com/antimatter15/jsgif/blob/master/NeuQuant.js to make the palette? (That project has some bugs with colors, but I don't know if it is in the quantization or the encoding.)
Yes, the way that the GIF format is specified it is max 8-bit (256 color) indexed color. The palette is supplied in the GIF, so you must also supply it to omggif.
There are many different color reduction / quantization algorithms that you can use for choosing a palette. This is really independent of omggif / gif encoding. I don't think there should be any problem using the above NeuQuant code w/ omggif, for example. Additionally you may also want to do dither, which is normally another independent pass.
When I have some more time I planned on working on dithering / color quantization (for example spatial color quantization and other algorithms). This would be a separate project from omggif, but I realize it would be helpful here too...
If you're going to monochrome 256 colors, there is no reason to dither.
For anybody interested, here is OMGGIF working with NeuQuant.js in a worker: https://github.com/meemoo/iframework/blob/master/libs/omggif/omggif-worker.js
Live test with webcam: http://meemoo.org/iframework/#example/cam2gif