What Does the JPEG End of Image Marker Mean?

The End of Image (EOI) marker is a critical structural element in the JPEG file format that signals the absolute conclusion of the encoded image data stream. This article explains what the EOI marker is, its specific hexadecimal representation, its role in preventing decoding errors, and what happens when an image viewer encounters a file where this marker is corrupted or missing.

The Anatomy of the EOI Marker

In the JPEG standard (ITU-T T.81 / ISO/IEC 10918-1), JPEG files are organized into structured segments demarcated by two-byte codes known as markers. Every marker begins with the byte 0xFF, followed by a specific byte that defines its function.

The End of Image marker is defined by the two-byte sequence:

It pairs conceptually with the Start of Image (SOI) marker (0xFF 0xD8), which sits at the very beginning of the file to declare the start of the JPEG stream.

What the Marker Indicates

The primary purpose of the EOI marker is to inform the decoder that the entropy-coded scan data has terminated. Specifically, it indicates:

  1. Completion of Compressed Data: Before the EOI marker, the decoder processes a continuous bitstream of Huffman- or arithmetic-coded image components. Because this stream is variable in length and does not store a predefined byte count, the decoder relies on the 0xFFD9 marker to know exactly when to cease decompression.
  2. Resource Deallocation: Once the decoder reads the EOI marker, it finalizes the rendering pipeline, closes the active image buffer, and displays the reconstructed pixels on the screen.
  3. Boundary for Trailing Data: Any bytes appearing after 0xFFD9 are not part of the visible image payload. This boundary is frequently used to store appended information, such as embedded thumbnails, secondary metadata chunks, digital signatures, or trailing archive payloads, without interfering with the primary image rendering.

What Happens If the EOI Marker Is Missing?

When a file transfer is interrupted or a storage drive suffers data loss, JPEG files are often truncated before the EOI marker can be written. The consequences depend on the decoder implementation: