Introduction
QOI is a lossless image format for RGB and RGBA images, designed by Dominic Szablewski and published in 2021. Its whole specification fits on one page. It compresses less well than PNG but encodes and decodes many times faster, and the reference encoder and decoder are a few hundred lines of C.
It is used in games, tools and embedded projects that want fast lossless images without a large library.
Structure
A QOI file is a 14-byte header, a stream of chunks and an 8-byte end marker. The
header is the magic qoif, the width and height as 32-bit big-endian
numbers, the number of channels (3 or 4) and a colour space byte (0 for sRGB with
linear alpha, 1 for all channels linear).
The pixels are coded in order from the top left, each as one of six operations: a
full RGB or RGBA value, an index into a 64-entry table of recently seen colours, a
small difference from the previous pixel, a larger difference based on the green
channel, or a run of repeats of the previous pixel. The end marker is seven zero bytes
followed by 01.
0Magicqoif4 bytes4Width, height big-endian8 bytes12Channels, colour space2 bytes14Chunks the coded pixelsvaries…End marker00 00 00 00 00 00 00 018 bytes
Links
Software
- GIMP (Windows, macOS, Linux)
- ImageMagick (Windows, macOS, Linux)
Developers
- qoi.h, the single-file C reference encoder and decoder
Reference
- qoiformat.org, the format's home page, with the one-page specification