Software

Find out how to reduce colors

Before you save a full-color image as a GIF or make an existing GIF smaller, you have to reduce the colors. Here's how.

By Paul Anderson

If you want to save a full-color image as a GIF or make an existing GIF smaller, you'll need to reduce the colors. Any image editor capable of saving GIFs will have a mechanism for color reduction; look for an Optimization panel or check the menus for Indexed Color, Reduce Colors, 256 Colors, or 8-Bit.

You'll typically have a few additional options at this point. One is dithering the image. However, unless you're being forced to make a GIF from a photograph, this is generally not a good idea. Dithering makes images more complex, resulting in a larger file size.

Another option is to reduce the image's color palette; the fewer colors it has, the smaller its file size. Try different bit depths (256 colors, 128, 64, 32, and so on)—with Undo commands between them—to find the smallest palette that still delivers acceptable image quality.

Original 128 colors 32 colors 8 colors

You can do a few more things to improve the appearance of the reduced image. First, reduce the bit depth gradually—going from 256 colors to 128 to 64 to 32 can produce better results than going straight to 32 colors.

Next, after reducing the image almost as far as you want, you can guide it the rest of the way by editing the palette yourself (look for Palette or Color Table in your image editor's panels or menus). Find similar colors that don't need to be differentiated, such as multiple shades of off-white or near-black. Modern tools let you delete selected colors from the palette. If you don't have that option, change the similar colors to identical values, then switch the image into RGB mode and back into indexed color. The duplicate palette entries should be replaced by a single entry.

Web-safe colors

An important consideration when dealing with Web graphics is the Web-safe palette. This was Netscape's clever solution to the problem of simultaneously displaying several GIFs with different indexed color palettes on a screen with an 8-bit color display. The browser imposes a single palette on all of the images, dithering or substituting based on the user's preferences. To make the single palette equally usable by all the images, it consists of colors that use six equal gradations in each RGB channel: 0, 51, 102, 153, 204, and 255 (which you'll often see in HTML as the hexidecimal values 33, 66, 99, CC, and FF). The resulting 216 colors compose the Web-safe palette. By producing images mainly or entirely from those 216 colors, you can be sure the images undergo little or no alteration on 8-bit screens and look more or less the same everywhere they appear.

Most image editors offer the Web-safe palette (also called the Netscape palette) in their color-reduction mechanisms. In Photoshop 3.0, which preceded this trend, you can derive the Netscape palette by entering 216 colors and selecting Uniform. This will get you the entire palette, so switch to RGB mode and back (this time selecting the Exact palette) to flush out the unused colors.

Paul Anderson is associate technical editor for CNET Builder.com. His responsibilities don't include handling graphics, so naturally, he handles them all the time.

Editor's Picks