wire / wire-format / jpeg-markers
A JPEG file is a sequence of segments, each starting with a marker: 0xFF followed by a non-zero, non-0xFF byte. Standalone markers (SOI 0xFFD8, EOI 0xFFD9, RSTn 0xFFD0-0xFFD7) have no length. All others carry a 2-byte big-endian length (including the length field itself) followed by that many bytes of payload. Common markers: SOF0 (0xFFC0 baseline DCT), DHT (0xFFC4 Huffman table), DQT (0xFFDB quantization table), SOS (0xFFDA start of scan), APP0 (0xFFE0 JFIF), APP1 (0xFFE1 Exif).
aka: JPEG marker structure
spec: ITU-T T.81 / ISO/IEC 10918-1
A JPEG file is a sequence of segments, each starting with a marker: 0xFF followed by a non-zero, non-0xFF byte. Standalone markers (SOI 0xFFD8, EOI 0xFFD9, RSTn 0xFFD0-0xFFD7) have no length. All others carry a 2-byte big-endian length (including the length field itself) followed by that many bytes of payload. Common markers: SOF0 (0xFFC0 baseline DCT), DHT (0xFFC4 Huffman table), DQT (0xFFDB quantization table), SOS (0xFFDA start of scan), APP0 (0xFFE0 JFIF), APP1 (0xFFE1 Exif).
| field | size | meaning |
|---|---|---|
| Marker prefix | 1 byte | 0xFF. |
| Marker code | 1 byte | 0x00 (stuffed byte) or 0x01 (TEM) or 0xD0-0xD9 (standalone) or 0xC0-0xCF/0xDA-0xFE (with length). |
| Length | 2 bytes | Payload length + 2, big-endian (only for markers with payload). |
| Payload | = length - 2 | Marker-specific data (SOF dimensions, DQT tables, SOS component specs, APP metadata, ...). |
| Entropy-coded data | variable | After SOS, the entropy-coded segment runs until the next 0xFF 0x00-stuffed or 0xFF (non-zero) marker; 0xFF 0x00 is a stuffed zero. |
example:
ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00
SOI + APP0 (JFIF) + DQT (quantization table) start
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/jpeg-markers
or /wire-format/jpeg-markers.json