GIF Image Descriptor Packed Fields Bit Structure

In the Graphics Interchange Format (GIF) specification—both GIF87a and GIF89a—the Image Descriptor block introduces each individual image frame. This block contains a critical one-byte configuration field known as the Packed Fields byte, located at offset 9 of the 10-byte descriptor. This article details the specific 8-bit layout of this byte, breaking down how each bit controls local color palettes, interlacing schemes, and palette sizes.

Image Descriptor Overview

The Image Descriptor consists of 10 consecutive bytes arranged as follows:

Bit Structure of the Packed Fields Byte

The Packed Fields byte assigns distinct operational flags and values across its 8 bits, read from most significant bit (Bit 7) to least significant bit (Bit 0):

Bit:    7   6   5   4   3   2   1   0
Field:  M   I   S   R   R   <-- N -->

Bit 7: Local Color Table Flag (M)

Bit 6: Interlace Flag (I)

Bit 5: Sort Flag (S)

Bits 4–3: Reserved (R)

Bits 2–0: Size of Local Color Table (N)

If Bit 7 is set to 0, the value of Bits 2–0 is ignored by standard decoders.