In GIF image data, what compression code resets the coding dictionary?
Answer
CLEAR code
Answer
CLEAR code
In GIF image data, the CLEAR code resets the coding dictionary.
GIF image data uses Lempel–Ziv–Welch (LZW) compression. A decoder begins with codes representing the image’s palette entries, then builds a dictionary of longer pixel strings as it reads the compressed stream. Reusing those strings is what makes GIF files smaller than raw pixel data.
The dictionary has a limited code space. When an encoder needs to restart the process, it emits the CLEAR code. The decoder then discards its accumulated string table and returns to the initial palette-based dictionary. CLEAR is therefore a control code, not a pixel color or an animation command.
A common mix-up is STOP, also called the end-of-information code. STOP ends the image-data stream; it does not reset compression. GIF’s LZW data also includes a minimum code size and packs variable-width codes into sub-blocks of up to 255 bytes. CLEAR may be inserted whenever needed, including before the dictionary becomes full, so encoders can manage dictionary growth and compression efficiency.
Source: Wikipedia · fact-checked Sept. 2026