Optimizing Animated GIFs
As with any file served over the Web, it is important to keep animated GIFs as small as possible. I recommend reading “Optimizing Animated GIFs,” an article and tutorial by Andrew King that appeared in WebReference.com in 1997, and from which many of the following tips were summarized (with permission). You can find it at http://www.webreference.com/dev/gifanim/index.html.
Image Compression
Start by applying the same file-size reduction tactics used on regular, static GIF files to the images in your animation frames. For more information, see Section 14.8. These measures include:
Eliminating unnecessary dithering
Removing stray pixels from otherwise solid areas
Reducing the number of colors
Reducing the bit depth
Optimizing Methods
In addition to the standard image-compressing methods, GIF animation tools optimize animations by eliminating the repetition of pixels in unchanging image areas. Only the pixels that change are recorded for each frame. Different tools use different optimizing methods, which are not created equal in terms of efficiency. These methods, in order from least to most compression, include:
- Minimum Bounding Rectangle
In this method, the changed portion of the image is saved, but it is always saved in the smallest rectangular area necessary to contain the changed pixels.
- Frame Differencing
In frame differencing, only the individual pixels that change are stored for each frame. This is a more efficient method than Minimum Bounding Rectangle, ...
Get Web Design in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.