QOI (image Format)
   HOME

TheInfoList



OR:

The Quite OK Image Format (QOI) is a specification for
lossless Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information. Lossless compression is possible because most real-world data exhibits statisti ...
image compression Image compression is a type of data compression applied to digital images, to reduce their cost for computer data storage, storage or data transmission, transmission. Algorithms may take advantage of visual perception and the statistical properti ...
of
24-bit Notable 24-bit machines include the CDC 924 – a 24-bit version of the CDC 1604, CDC lower 3000 series, SDS 930 and SDS 940, the ICT 1900 series, the Elliott 4100 series, and the Datacraft minicomputers/ Harris H series. The term SWORD ...
(8
bit The bit is the most basic unit of information in computing and digital communication. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented as ...
s per color
RGB The RGB color model is an additive color model in which the red, green, and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three ...
) or 32-bit (8 bits per color with 8-bit
alpha Alpha (uppercase , lowercase ) is the first letter of the Greek alphabet. In the system of Greek numerals, it has a value of one. Alpha is derived from the Phoenician letter ''aleph'' , whose name comes from the West Semitic word for ' ...
channel
RGBA RGBA stands for red green blue alpha. While it is sometimes described as a color space, it is actually a three-channel RGB color model supplemented with a fourth ''alpha channel''. Alpha indicates how opaque each pixel is and allows an image to ...
) color
raster file:Rgb-raster-image.svg, upright=1, The Smiley, smiley face in the top left corner is a raster image. When enlarged, individual pixels appear as squares. Enlarging further, each pixel can be analyzed, with their colors constructed through comb ...
(bitmapped) images, invented by Dominic Szablewski and first announced on 24 November 2021.


Description

The intended purpose was to create an
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
lossless compression Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information. Lossless compression is possible because most real-world data exhibits statisti ...
method that was faster and easier to implement than PNG. Figures specified in the blog post announcing the format claim 20-50 times faster encoding, and 3-4 times faster decoding speed compared to PNG, with similar file sizes. The author has donated the specification to the
public domain The public domain (PD) consists of all the creative work to which no Exclusive exclusive intellectual property rights apply. Those rights may have expired, been forfeited, expressly Waiver, waived, or may be inapplicable. Because no one holds ...
( CC0).


Software and language support

QOI is supported by
FFmpeg FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the command-line ffmpeg tool itself, designed for processing vide ...
(v5.1+),
GIMP Gimp or GIMP may refer to: Clothing * Bondage suit, also called a gimp suit, a type of suit used in BDSM * Bondage mask, also called a gimp mask, often worn in conjunction with a gimp suit Embroidery and crafts * Gimp (thread), an ornamental tr ...
(v3.0+), GraphicConverter (v11.8+), ImageGlass (v8.5+, read-only),
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. ImageMagick was created by John Cristy in 1987, and it ...
(v7.1.0-20+), Imagine (v1.3.9+), and
IrfanView IrfanView () is an image viewer, editor, organiser and converter program for Microsoft Windows. It can also play video and audio files, and has some image creation and painting capabilities. IrfanView is free for non-commercial use; commercial ...
(v4.60+, with plugin).
Microsoft PowerToys Microsoft PowerToys is a set of freeware (later open source) system utilities designed for power users developed by Microsoft for use on the Windows operating system. These programs add or change features to maximize productivity or add more cu ...
(v0.76+) for Windows 10 and 11 adds support for previewing QOI images to
File Explorer File Explorer, previously known as Windows Explorer, is a file manager application and default desktop environment that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user i ...
. Community made plugins are available in
GIMP Gimp or GIMP may refer to: Clothing * Bondage suit, also called a gimp suit, a type of suit used in BDSM * Bondage mask, also called a gimp mask, often worn in conjunction with a gimp suit Embroidery and crafts * Gimp (thread), an ornamental tr ...
, Paint.NET and XnView MP. The game engine
GameMaker GameMaker (originally Animo, Game Maker (until 2011) and GameMaker Studio) is a series of cross-platform game engines created by Mark Overmars in 1999 and developed by YoYo Games since 2007. The latest iteration of ''GameMaker'' was released ...
has used a combination of
bzip2 bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities such as tar for tasks such as handli ...
and QOI as the default storage format for
texture Texture may refer to: Science and technology * Image texture, the spatial arrangement of color or intensities in an image * Surface texture, the smoothness, roughness, or bumpiness of the surface of an object * Texture (roads), road surface c ...
groups since version 2022.1.0.609. Despite being smaller, files in the format decompress faster than those in the PNG format it displaced. The engine also offers plain QOI for increased decompression performance, and PNG for compatibility with tooling and web platforms. There are also implementations for various
languages Language is a structured system of communication that consists of grammar and vocabulary. It is the primary means by which humans convey meaning, both in spoken and signed forms, and may also be conveyed through writing. Human language is ch ...
such as
Rust Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH) ...
,
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
,
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, C++, C# and more. A full list can be found on th
project's Git(Hub) repository README


File format


Header

A QOI file consists of a 14-byte header, followed by any number of data “chunks” and an 8-byte end marker. qoi_header ; The colorspace and channel fields are purely informative. They do not change the way data chunks are encoded.


Encoding

Images are encoded row by row, left to right, top to bottom. The decoder and encoder start with as the previous pixel value. An image is complete when all
pixel In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a Raster graphics, raster image, or the smallest addressable element in a dot matrix display device. In most digital display devices, p ...
s specified by have been covered. Pixels are encoded as: *
Run-length encoding Run-length encoding (RLE) is a form of lossless data compression in which ''runs'' of data (consecutive occurrences of the same data value) are stored as a single occurrence of that data value and a count of its consecutive occurrences, rather th ...
of the previous pixel () * an index into the array of previously seen pixels () * a difference compared to the previous pixel value in r,g,b ( or ) * Full r,g,b or r,g,b,a values ( or ) The color channels are assumed to not be premultiplied with the alpha channel (“un-premultiplied alpha”). A running (zero-initialized) of previously seen pixel values is maintained by the encoder and decoder. Each pixel that is seen by the encoder and decoder is put into this array at the position formed by a
hash function A hash function is any Function (mathematics), function that can be used to map data (computing), data of arbitrary size to fixed-size values, though there are some hash functions that support variable-length output. The values returned by a ...
of the color value. In the encoder, if the pixel value at the index matches the current pixel, this index position is written to the stream as . The hash function for the index is: index_position = (r * 3 + g * 5 + b * 7 + a * 11) % 64 Each chunk starts with a 2- or 8-bit tag, followed by a number of data bits. The bit length of chunks is divisible by 8 - i.e. all chunks are byte aligned. All values encoded in these data bits have the most significant bit on the left. The 8-bit tags have precedence over the 2-bit tags. A decoder must check for the presence of an 8-bit tag first. The byte stream's end is marked with 7 bytes followed by a single byte. The possible chunks are:


* 8-bit tag (254) * 8-bit red channel value * 8-bit green channel value * 8-bit blue channel value The alpha value remains unchanged from the previous pixel.


* 8-bit tag (255) * 8-bit red channel value * 8-bit green channel value * 8-bit blue channel value * 8-bit alpha channel value


* 2-bit tag * 6-bit index into the color index array: A valid encoder must not issue 2 or more consecutive chunks to the same index. should be used instead.


* 2-bit tag * 2-bit red channel difference from the previous pixel * 2-bit green channel difference from the previous pixel * 2-bit blue channel difference from the previous pixel The difference to the current channel values are using a wraparound operation, so will result in 255, while will result in 0. Values are stored as unsigned integers with a bias of 2. E.g. −2 is stored as 0 (). 1 is stored as 3 (). The alpha value remains unchanged from the previous pixel.


* 2-bit tag * 6-bit green channel difference from the previous pixel * 4-bit red channel difference minus green channel difference * 4-bit blue channel difference minus green channel difference The green channel is used to indicate the general direction of change and is encoded in 6 bits. The red and blue channels (dr and db) base their diffs off of the green channel difference. I.e.: dr_dg = (cur_px.r - prev_px.r) - (cur_px.g - prev_px.g) db_dg = (cur_px.b - prev_px.b) - (cur_px.g - prev_px.g) The difference to the current channel values are using a wraparound operation, so will result in 253, while will result in 1. Values are stored as unsigned integers with a bias of 32 for the green channel and a bias of 8 for the red and blue channel. The alpha value remains unchanged from the previous pixel.


* 2-bit tag * 6-bit run-length repeating the previous pixel The run-length is stored with a bias of −1. Note that the runlengths 63 and 64 ( and ) are illegal as they are occupied by the and tags.


References


External links


Format website: C Source code and benchmark results

1 page PDF specification

GitHub repository (including C implementation)

How PNG Works: Compromising Speed for Quality - YouTube
A video comparing compression techniques in PNG and QOI with animations and examples. {{Authority control Computer-related introductions in 2021 Graphics standards Image compression Open formats Raster graphics file formats