Filename extension | .qoi |
---|---|
Magic number | qoif (4 bytes, ASCII) |
Developed by | Dominic Szablewski |
Initial release | 24 November 2021 |
Latest release | 1.0 5 January 2022 |
Type of format | Lossless bitmap image format |
Standard | Specification |
Open format? | Yes |
Free format? | Yes |
Website | qoiformat.org |
The Quite OK Image Format (QOI) is a specification for lossless image compression of 24-bit (8 bits per color RGB) or 32-bit (8 bits per color with 8-bit alpha channel RGBA) color raster (bitmapped) images, invented by Dominic Szablewski and first announced on 24 November 2021. [1]
The intended purpose was to create an open source lossless compression 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. [1] The author has donated the specification to the public domain (CC0). [2]
QOI is supported natively by ImageMagick, [3] Imagine (v1.3.9+), IrfanView (v4.60+), [4] FFmpeg (v5.1+), [5] and GraphicConverter (v11.8+). [6] Microsoft PowerToys (v0.76+) for Windows 10 and 11 adds support for previewing QOI images to the Windows File Explorer. [7] [8] Community made plugins are available in GIMP, Paint.NET and XnView MP. [9]
The game engine GameMaker designates bzip2 + QOI as the default format of texture groups since version 2022.1.0.609, to achieve the better compression but still quicker to decompress, while the standalone QOI and PNG formats are optional for the even faster performance and better compabilities respectively. [10] [11]
There are also implementations for various languages such as Rust, Python, Java, C++, C# and more. [12] A full list can be found on the project's Git(Hub) repository README.
A QOI file consists of a 14-byte header, followed by any number of data “chunks” and an 8-byte end marker.
qoi_header{charmagic[4];// magic bytes "qoif"uint32_twidth;// image width in pixels (BE)uint32_theight;// image height in pixels (BE)uint8_tchannels;// 3 = RGB, 4 = RGBAuint8_tcolorspace;// 0 = sRGB with linear alpha// 1 = all channels linear};
The colorspace and channel fields are purely informative. They do not change the way data chunks are encoded.
Images are encoded row by row, left to right, top to bottom. The decoder and encoder start with {r:0, g:0, b:0, a:255}
as the previous pixel value. An image is complete when all pixels specified by width * height
have been covered. Pixels are encoded as:
QOI_OP_RUN
)QOI_OP_INDEX
)QOI_OP_DIFF
or QOI_OP_LUMA
)QOI_OP_RGB
or QOI_OP_RGBA
)The color channels are assumed to not be premultiplied with the alpha channel (“un-premultiplied alpha”). A running array[64]
(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 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 QOI_OP_INDEX
. 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 0x00
bytes followed by a single 0x01
byte.
The possible chunks are:
QOI_OP_RGB
Byte[0] | Byte[1] | Byte[2] | Byte[3] | |||||||
---|---|---|---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | red | green | blue |
b11111110
(254)The alpha value remains unchanged from the previous pixel.
QOI_OP_RGBA
Byte[0] | Byte[1] | Byte[2] | Byte[3] | Byte[4] | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | red | green | blue | alpha |
b11111111
(255)QOI_OP_INDEX
Byte[0] (Range: 0 .. 63) | |||||||
---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
0 | 0 | index |
b00
0..63
A valid encoder must not issue 2 or more consecutive QOI_OP_INDEX
chunks to the same index. QOI_OP_RUN
should be used instead.
QOI_OP_DIFF
Byte[0] (Range: 64 .. 127) | |||||||
---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
0 | 1 | dr | dg | db |
b01
-2..1
-2..1
-2..1
The difference to the current channel values are using a wraparound operation, so 1 - 2
will result in 255, while 255 + 1
will result in 0.
Values are stored as unsigned integers with a bias of 2. E.g. −2 is stored as 0 (b00
). 1 is stored as 3 (b11
). The alpha value remains unchanged from the previous pixel.
QOI_OP_LUMA
Byte[0] (Range: 128 .. 191) | Byte[1] | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
1 | 0 | dg | dr - dg | db - dg |
b10
-32..31
-8..7
-8..7
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 10 - 13
will result in 253, while 250 + 7
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.
QOI_OP_RUN
Byte[0] (Range: 192 .. 253) | |||||||
---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
1 | 1 | run |
b11
The run-length is stored with a bias of −1. Note that the runlengths 63 and 64 (b111110
and b111111
) are illegal as they are occupied by the QOI_OP_RGB
and QOI_OP_RGBA
tags. [13]
In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate passes or layers and then combine the resulting 2D images into a single, final image called the composite. Compositing is used extensively in film when combining computer-rendered image elements with live footage. Alpha blending is also used in 2D computer graphics to put rasterized foreground elements over a background.
The Graphics Interchange Format is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987.
JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression with little perceptible loss in image quality. Since its introduction in 1992, JPEG has been the most widely used image compression standard in the world, and the most widely used digital image format, with several billion JPEG images produced every day as of 2015.
Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF)—unofficially, the initials PNG stood for the recursive acronym "PNG's not GIF".
PCX, standing for PiCture eXchange, is an image file format developed by the now-defunct ZSoft Corporation of Marietta, Georgia, United States. It was the native file format for PC Paintbrush and became one of the first widely accepted DOS imaging standards, although it has since been succeeded by more sophisticated image formats, such as BMP, JPEG, and PNG. PCX files commonly store palette-indexed images ranging from 2 or 4 colors to 16 and 256 colors, although the format has been extended to record true-color (24-bit) images as well.
Gamma correction or gamma is a nonlinear operation used to encode and decode luminance or tristimulus values in video or still image systems. Gamma correction is, in the simplest cases, defined by the following power-law expression:
The BMP file format, or bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device, especially on Microsoft Windows and OS/2 operating systems.
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 be combined over others using alpha compositing, with transparent areas and anti-aliasing of the edges of opaque regions. Each pixel is a 4D vector.
Interleaved Bitmap (ILBM) is an image file format conforming to the Interchange File Format (IFF) standard. The format originated on the Amiga platform, and on IBM-compatible systems, files in this format or the related PBM format are typically encountered in games from late 1980s and early 1990s that were either Amiga ports or had their graphical assets designed on Amiga machines.
Truevision TGA, often referred to as TARGA, is a raster graphics file format created by Truevision Inc.. It was the native format of TARGA and VISTA boards, which were the first graphic cards for IBM-compatible PCs to support high color or true color display. This family of graphic cards was intended for professional computer image synthesis and video editing with PCs; for this reason, usual resolutions of TGA image files match those of the NTSC and PAL video formats.
pngcrush is a free and open-source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly – that is, the resulting "crushed" image will have the same quality as the source image.
S3 Texture Compression (S3TC) is a group of related lossy texture compression algorithms originally developed by Iourcha et al. of S3 Graphics, Ltd. for use in their Savage 3D computer graphics accelerator. The method of compression is strikingly similar to the previously published Color Cell Compression, which is in turn an adaptation of Block Truncation Coding published in the late 1970s. Unlike some image compression algorithms, S3TC's fixed-rate data compression coupled with the single memory access made it well-suited for use in compressing textures in hardware-accelerated 3D computer graphics. Its subsequent inclusion in Microsoft's DirectX 6.0 and OpenGL 1.3 led to widespread adoption of the technology among hardware and software makers. While S3 Graphics is no longer a competitor in the graphics accelerator market, license fees have been levied and collected for the use of S3TC technology until October 2017, for example in game consoles and graphics cards. The wide use of S3TC has led to a de facto requirement for OpenGL drivers to support it, but the patent-encumbered status of S3TC presented a major obstacle to open source implementations, while implementation approaches which tried to avoid the patented parts existed.
Netpbm is an open-source package of graphics programs and a programming library. It is used mainly in the Unix world, where one can find it included in all major open-source operating system distributions, but also works on Microsoft Windows, macOS, and other operating systems.
The ICO file format is an image file format for computer icons in Microsoft Windows. ICO files contain one or more small images at multiple sizes and color depths, such that they may be scaled appropriately. In Windows, all executables that display an icon to the user, on the desktop, in the Start Menu, or in file Explorer, must carry the icon in ICO format.
An image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be compressed or uncompressed. If the data is compressed, it may be done so using lossy compression or lossless compression. For graphic design applications, vector formats are often used. Some image file formats support transparency.
The Apple Icon Image format (.icns) is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states. The fixed-size icons can be scaled by the operating system and displayed at any intermediate size.
Silicon Graphics Image (SGI) or the RGB file format is the native raster graphics file format for Silicon Graphics workstations. The format was invented by Paul Haeberli. It can be run-length encoded (RLE). FFmpeg and ImageMagick, among others, support this format.
PVRTC and PVRTC2 are a family of lossy, fixed-rate texture compression formats used in PowerVR's MBX, SGX and Rogue technologies. The PVRTC algorithm is documented in Simon Fenney's paper "Texture Compression using Low-Frequency Signal Modulation" that was presented at Graphics Hardware 2003.
Ericsson Texture Compression (ETC) is a lossy texture compression technique developed in collaboration with Ericsson Research in early 2005. It was originally developed under the name iPACKMAN and based on an earlier compression scheme called iPACKMAN.
Free Lossless Image Format (FLIF) is a lossless image format claiming to outperform PNG, lossless WebP, lossless BPG and lossless JPEG 2000 in terms of compression ratio on a variety of inputs.