Every QOI file starts with the same 14 bytes. All multi-byte numbers in the format are big-endian. There is only one version of the format, and the header has no version field.
Fields
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | ASCII | magic | The text qoif: 71 6F 69 66. |
| 4 | 4 | u32 | width | Image width in pixels. |
| 8 | 4 | u32 | height | Image height in pixels. |
| 12 | 1 | u8 | channels | See Channels. |
| 13 | 1 | u8 | colorspace | See Colour space. |
Channels
| Value | Meaning |
|---|---|
| 3 | RGB |
| 4 | RGBA |
The value does not change how chunks are coded. An RGB file still carries a running alpha value, which stays at 255 unless a chunk changes it.
Colour space
| Value | Meaning |
|---|---|
| 0 | sRGB colour channels with linear alpha |
| 1 | All channels linear |
The specification calls this byte informative: it is saved in the header but does not affect how chunks are encoded or decoded.
Limits
The format itself sets no maximum beyond the 32-bit width and height. The reference
implementation, qoi.h, refuses images of more than 400,000,000 pixels
(QOI_PIXELS_MAX), which keeps the worst case of five bytes per pixel under
about 2 GB. That limit belongs to the library, not to the file format.
Example
A 2 by 1 RGBA image in sRGB:
00000000 71 6F 69 66 00 00 00 02 00 00 00 01 04 00
The rest of this file is taken apart at the end of the Chunks page.