I've exported an animation to animated GIF, which generated a 15mb file. I've been asked if I could regenerate the file, limiting it to only 16 colors, but I can't find any documentation on how I might do that. Is there a way to make Export[] reduce the color palette, preferably dithering as needed?
Tell me more
×
Mathematica Stack Exchange is a question and answer site for
users of Mathematica. It's 100% free, no registration required.
|
|
|||
| show 1 more comment |
|
Just too long for a comment. Here you can see the savings obtained by using the method explained in Heike's comment above:
|
|||||
|
Export[]in old versions of Mathematica supported a"ColorReductionPalette"option for exporting GIFs; it seems they have either removed or hidden this functionality. As for dithering, it seems Floyd-Steinberg dithering is already performed by default when exporting GIFs. – J. M.♦ Jun 8 '12 at 9:48Export["image.gif", ColorQuantize[#, 16] & /@ imglist]. – Heike Jun 8 '12 at 14:47gifsicle --colors=256 --optimize=2 < in.gif > out.gif– Jens Jun 9 '12 at 5:13gifsicle --optimize=3 --colors=16 < enormous.gif > smaller.gifproduces a file half the size of the original 15 megabyte animated GIF file in question. The source animation uses very few colors anyway so 16 colors seems sufficient to my eye... – Jeff Atwood♦ Jun 9 '12 at 11:44