Eight-Bit Indexed Color

GIF files are indexed color images that can contain a maximum of 8-bit color information (they can also be saved at lower bit rates). This means they can contain up to 256 colors—the maximum number that 8 bits of information can define (28 = 256). Lower bit-depths result in fewer colors and may also reduce file size. This is discussed in Section 14.8 at the end of this chapter.

“Indexed color” means that the set of colors in the image, its palette, is stored in a color table. Each pixel in the image contains a reference (or “index”) to a table cell containing the color for that pixel. In Photoshop, you can view the table for an indexed color image by selecting Image Mode Color Table.

When you convert a 24-bit (millions of colors) image to GIF, it is necessary to first convert the image to Indexed Color mode, and as part of that process, reduce the number of colors to a palette of 256 or fewer colors. The image editing tool does its best to approximate the full color range by using the most appropriate colors to approximate the image (an “adaptive” palette). You can specify an alternate set of colors to use in this process, such as the Web Palette.

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.