Reduce gif file size (tried optimize, optimizePlus, deconst)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Post by anthony »

I talk about animation and optimization and tools that compress images whcih have already been saved to GIF format generally does so in two ways.

The first is to use various forms of compression optimization. Basically they convert any or only some pixels that did not change from the previous frames to transparency. This lets you get longer runs or areas of transparency which compresses better than a random sequence of color pixels.

The results from vary enormously from program to program, as they implement different ways of selecting what pixels should be made transparent.

The second is more evasive. they not only replace colors that do NOT change, but also colors that only change slightly! That is the results will not be an exact match to the original animation but have small usually un-noticeable color changes.

For more information look at my notes in IM Example Usage, Compression Optimization
http://www.imagemagick.org/Usage/anim_opt/#compress_opt

If the data has NOT yet been converted to GIF then you have more areas of optimization, including color reductions, Frame Optimization, and even optimizations involving adding extra frames to the animation sequence!
See the rest of the page referenced by the above link.

Finally color reductions usually involve dither and how you dither the color can make a BIG difference to the GIf compression you get. See the page on Video Handling for one example of this.
http://www.imagemagick.org/Usage/video/#gif

Now I'll have a look at what you have provided!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Post by anthony »

NOTES on my findings...

First -deconstruct is a depreciated frame optimization technique.

Second looking at the "complete.miff" you have very few colors in the image, and mostly all solid areas. As Error Correction Dithers (the default used by IM) will generally produce a problem for animation known as dither noise. See
http://www.imagemagick.org/Usage/quantize/#dither_prob

The dithering would generally result in a noisy, always changing 'zig-zag' edges as you noted. As your image is extremely cartoon like, I would ignore dithering completely and just turn it off, using +dither. The number of colors in color reduction would then only result in how smooth the edges was, and NOT a noisy zig-zag effect.

Looking at the fireworks animation. It looks like it performed well with basic frame optimization, and even LWZ compression optimization, something that gifsicle will do with an -02 flag. I am not certian how it did color reduction but it isn't too bad.
Fireworks example size was 25375 bytes which is very good.

Now lets use IM to optimize, though it does not provide LWZ compression optimization like fireworks.

Code: Select all

   convert complete.miff +dither -layers Optimize -colors 32 im_opt.gif
result is 70138 bytes. Change to 16 colors still looked quite good, but only reduced it to 64908 bytes. It produced the same frame optimization as fireworks, well almost. The last frame size was slightly different. which could be the result of color reduction differences.

taking the 32 color IM version and feeding it to gifsicle

Code: Select all

gifsicle -O2 im_opt.gif -o im_gifsicle_opt.gif
dropped the optimization down to 32830 whcih is close to what fireworks provides.

The differences is how GOOD the LWZ compression optimization is between the two programs. I would say fireworks, being a commercial product, has produced a much better heuristic that gifsicle, and thus better results.

If file size is this important to you (and obviously is) I suggest you use fireworks. IM (and gifsicle) can not compete.


However please let me know what you find out from teh fire works manual on its color reduction, and anything either that may be of interest for comparision.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
QooooQ

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Post by QooooQ »

Hmm, so its the LWZ compression, hmm, thought one could adjust some parameters or add some options.

Then I will use ImageMagick to make the first reduction (64 KB) and Gifsicle to further reduce to 32 KB.

Fireworks is no choice. Just a place where all this started in another division (hope its the right word). Now its html, php and commandline.


Thank you very very much for your efforts and explanations. Good to have you guys :D

Consider this topic closed :D


PS: Couldn't find anything regarding the fireworks way of doing the LWZ. But the gifsicle result is good too, right ? And its code is free. You could have a look in there ?! Maybe soon you will have integrated their algorithm.
Till then Gifsicle and ImageMagick will be a married couple in my application :D
Will also delete files from my server now.
Thank you
Post Reply