Animated .GIF optimization

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
Jones
Posts: 1
Joined: 2011-10-06T23:13:20-07:00
Authentication code: 8675308

Animated .GIF optimization

Post 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 =)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Animated .GIF optimization

Post 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/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Animated .GIF optimization

Post 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)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Animated .GIF optimization

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply