Page 1 of 1

Animated .GIF optimization

Posted: 2011-10-11T20:24:43-07:00
by Jones
Usually when I edit an animated .GIF with Adobe ImageReady I'm able to re-save it at the same file size. Sometimes I'll find a gif that increases in file size if I re-save it, even though I have made no changes to the image. So I'm wondering if there's an optimization method I've missed.

Here's an example image: http://i.imgur.com/7Fya9.gif

The file size is 496kb but when I re-save it with ImageReady, the file size doubles to 1M, even though I made no changes to the image.

Is ImageMagick able to re-save that image at the same 496kb file size? Any ideas about why the file size doubles in ImageReady?

Thanks =)

Re: Animated .GIF optimization

Posted: 2011-10-11T20:44:22-07:00
by anthony
The GIF animation contains a form of transparency optimization
http://www.imagemagick.org/Usage/anim_opt/#opt_trans

More than likely this is what ImageReady is removing from the GIF animation

You have a link to ImageReady version? I can then compare to see if any of the colors have changed.

The image could have been optimized better in the first place by using some type of order-dither quantization, such as shown in Video to GIF
http://www.imagemagick.org/Usage/video/

Re: Animated .GIF optimization

Posted: 2011-10-11T20:47:09-07:00
by fmw42
I am not an animation expert. The problem is likely in how your animation is created and optimized when copied. The best I could do in IM with my limited knowledge increases your file size from 500KB to 700KB either with a simple copy or with -layers optimizeframe. Other optimize methods increased it to over 1MB.

You probably should review:

http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_mods/

also
http://www.imagemagick.org/Usage/formats/#gif (esp. the non-IM tools for optimizing gifs)

Re: Animated .GIF optimization

Posted: 2011-10-11T22:01:33-07:00
by anthony
If IM just reads the image, in and out (no optimization change) the image is about 50% larger.

Code: Select all

convert 7Fya9.gif gif:- | wc -c
716022
original is 508675 bytes

It looks like what ever did the transparency optimization had extremely strong integration with the LWZ compression algorithm, so as to generate highly compressed image data.

More than likely it was optimized by some unknown, highly specialised video to GIF generator. For this level of optimization the original image is probably a must.

See Lossy LZW Optimization immediately below the link to Transparency Optimization.

PS I tried this on the gifsicle LWZ optimizer too, and it was worse that IM transparency optimization.