QOI (image format)

Quite OK Image
Filename extension
.qoi
Magic numberqoif (4 bytes, ASCII)
Developed byDominic Szablewski
Initial release24 November 2021
Latest release
1.0
5 January 2022; 2 years ago (2022-01-05)
Type of formatLossless bitmap image format
StandardSpecification
Open format?Yes
Free format?Yes
Websiteqoiformat.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]

Description

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]

Software and language support

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.

File format

A QOI file consists of a 14-byte header, followed by any number of data “chunks” and an 8-byte end marker.

qoi_header {
    char magic[4]; // magic bytes "qoif"
    uint32_t width; // image width in pixels (BE)
    uint32_t height; // image height in pixels (BE)
    uint8_t channels; // 3 = RGB, 4 = RGBA
    uint8_t colorspace; // 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.

Encoding

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:

  • Run-length encoding of the previous pixel (QOI_OP_RUN)
  • an index into the array of previously seen pixels (QOI_OP_INDEX)
  • a difference compared to the previous pixel value in r,g,b (QOI_OP_DIFF or QOI_OP_LUMA)
  • Full r,g,b or r,g,b,a values (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
  • 8-bit tag b11111110 (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.

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
  • 8-bit tag b11111111 (255)
  • 8-bit red channel value
  • 8-bit green channel value
  • 8-bit blue channel value
  • 8-bit alpha channel value

QOI_OP_INDEX

Byte[0] (Range: 0 .. 63)
7 6 5 4 3 2 1 0
0 0 index
  • 2-bit tag b00
  • 6-bit index into the color index array: 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
  • 2-bit tag b01
  • 2-bit red channel difference from the previous pixel -2..1
  • 2-bit green channel difference from the previous pixel -2..1
  • 2-bit blue channel difference from the previous pixel -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
  • 2-bit tag b10
  • 6-bit green channel difference from the previous pixel -32..31
  • 4-bit red channel difference minus green channel difference -8..7
  • 4-bit blue channel difference minus green channel difference -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
  • 2-bit tag b11
  • 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 (b111110 and b111111) are illegal as they are occupied by the QOI_OP_RGB and QOI_OP_RGBA tags.[13]

References

  1. ^ a b "Lossless Image Compression in O(n) Time". Phoboslab.org. 2021-11-24. Archived from the original on 2022-05-08. Retrieved May 1, 2022.
  2. ^ "QOI The Quite OK Image Format". qoiformat.org. 2023-12-14. Archived from the original on 2023-12-16. Retrieved December 14, 2023.
  3. ^ "ImageMagick - Image Formats". Archived from the original on January 2, 2022. Retrieved May 4, 2022.
  4. ^ "History of IrfanView Changes/Versions". www.irfanview.com. Archived from the original on 2021-01-14. Retrieved 2022-05-10.
  5. ^ "FFmpeg Changelog - Gitweb". ffmpeg.org. Archived from the original on 2022-07-13. Retrieved 2022-07-13.
  6. ^ "GraphicConverter Release Notes version 11.8 (build 5762)". Lemke Software. Archived from the original on 11 February 2023. Retrieved 21 February 2023.
  7. ^ "Release v0.76.0". Microsoft. Retrieved 26 March 2024.
  8. ^ "PowerToys File Explorer add-ons utility for Windows". learn.microsoft.com. 2023-12-04. Retrieved 2024-02-05.
  9. ^ James Hein (16 March 2022). "Moving images to the next level". Bangkok Post. Retrieved April 1, 2022.
  10. ^ "Version 2022.1.0.609". GameMaker Release Notes. YoYo Games. 26 January 2022. Retrieved 26 March 2024.
  11. ^ "Texture Groups". GameMaker Manual. YoYo Games. Retrieved 26 March 2024.
  12. ^ Simon Sharwood. "Developer creates 'Quite OK Image Format' – but it performs better than just OK". The Register. Archived from the original on 2023-06-02. Retrieved 2023-12-30.
  13. ^ Szablewski, Dominic (2022-01-05). "The Quite OK Image Format Specification" (PDF). Archived (PDF) from the original on 2022-04-30. Retrieved 2022-06-05. Public Domain This article incorporates text from this source, which is in the public domain.

Read other articles:

Cet article est une ébauche concernant le Texas et la criminologie. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Pour les articles homonymes, voir Byrd. L’affaire James Byrd, Jr. est une affaire criminelle américaine qui a défrayé la chronique en juin 1998, à la suite de la torture et du meurtre raciste le 7 juin 1998 à Jasper, au Texas d'un afro-américain, James Byrd, Jr. (né le 2 mai 1949) par troi...

 

Унсуе, Унсуе (ісп. Unzué) — муніципалітет в Іспанії. Хуан Карлос Унсуе (ісп. Juan Carlos Unzué, нар. 22 квітня 1967, Памплона) — іспанський футболіст. Унсуе — термін, який має кілька значень. Ця сторінка значень містить посилання на статті про кожне з них.Якщо ви потрапили сюди за внутрішн

 

Тепениця Коростенська дирекція Південно-Західна залізниця зупинний пунктРозташуванняРозташування с. ТепеницяКоординати 51°13′27″ пн. ш. 27°43′05″ сх. д. / 51.22417° пн. ш. 27.71806° сх. д. / 51.22417; 27.71806СтруктураЛінія(ї) Коростень — ОлевськПлатфор

Brazilian Grand PrixGrand Prix motorcycle racingVenueGoiânia (1987–1989)Interlagos (1992)First race1987Last race1992Most wins (rider)Luca Cadalora, Dominique Sarron (2)Most wins (manufacturer)Honda (5) The Brazilian motorcycle Grand Prix was a motorcycling road racing event that is part of the Grand Prix motorcycle racing World Championship. History The first official Brazilian Grand Prix was held in 1987 at the Autódromo Internacional Ayrton Senna in Goiânia. Two more races were hos...

 

Religión en Costa Rica (2021)[1]​ Gráfico no disponible temporalmente debido a problemas técnicos.      Catolicismo (47.5%)      Sin religión (27.0%)      Protestantismo (21.0%)      Testigo de Jehová (1.4%)      Mormones (0.3%)      Islam (0.1%)      Otra (2.7%) Basílica de Nuestra Señora de los Ángeles (C...

 

Removing sensitive information from a document to allow distribution For other uses, see Redaction (disambiguation). Redaction or sanitization is the process of removing sensitive information from a document so that it may be distributed to a broader audience. It is intended to allow the selective disclosure of information. Typically, the result is a document that is suitable for publication or for dissemination to others rather than the intended audience of the original document. When the in...

Air 1 radio station in Odem–Corpus Christi, Texas For KXAI at 103.7 FM prior to 2021, see KZAI. KMJR redirects here. For the radio station in Los Angeles that held the call sign KMJR from 2000 to 2001, see KDAY. KXAIOdem, TexasBroadcast areaCorpus Christi, TexasFrequency103.7 MHzProgrammingFormatChristian worship musicNetworkAir 1OwnershipOwnerEducational Media FoundationSister stationsKPLVHistoryFirst air dateApril 2, 1985 (1985-04-02)[1]Former call signsKXTO (1985...

 

Harmine Names Preferred IUPAC name 7-Methoxy-1-methyl-9H-pyrido[3,4-b]indole Identifiers CAS Number 442-51-3 Y 3D model (JSmol) Interactive image ChEBI CHEBI:28121 Y ChEMBL ChEMBL269538 Y ChemSpider 4444445 Y DrugBank DB07919 Y ECHA InfoCard 100.006.485 KEGG C06538 Y PubChem CID 5280953 UNII 4FHH5G48T7 Y CompTox Dashboard (EPA) DTXSID30196066 InChI InChI=1S/C13H12N2O/c1-8-13-11(5-6-14-8)10-4-3-9(16-2)7-12(10)15-13/h3-7,15H,1-2H3 YKey: BXNJHAXVSOCGB...

 

59°56′06″ пн. ш. 30°19′42″ сх. д. / 59.93500° пн. ш. 30.32833° сх. д. / 59.93500; 30.32833Координати: 59°56′06″ пн. ш. 30°19′42″ сх. д. / 59.93500° пн. ш. 30.32833° сх. д. / 59.93500; 30.32833 Невський проспект Петербурзький метрополітен Загальні даніТип ...

2004 Italian filmThe SpectatorDirected byPaolo FranchiStarringBarbora BobuľováCinematographyGiuseppe LanciMusic byCarlo CrivelliRelease date2004Running time98 minutesCountryItalyLanguageItalian The Spectator (Italian: La spettatrice) is a 2004 Italian romance-drama film written and directed by Paolo Franchi. It was screened at the 2004 Tribeca Film Festival.[1] The film was paired by several critics with the works by Krzysztof Kieślowski.[2][3][4] Cast Barbo...

 

1989 American filmA Sinful LifeTheatrical release posterDirected byWilliam SchreinerScreenplay byMelanie GrahamProduced byDaniel RaskovStarringAnita MorrisDennis ChristopherShelly DesaiRita GomezDavid LabiosaRick OvertonCinematographyJonathan WestEdited byJeffrey ReinerMusic byTodd HayenProductioncompanyNew Line CinemaDistributed byNew Line CinemaRelease date June 30, 1989 (1989-06-30) Running time90 minutesCountryUnited StatesLanguageEnglish A Sinful Life is a 1989 American co...

 

2012 Indian filmOm AllahDirected bySameer KhanWritten byFaisal SaifSameer KhanProduced byAushim KhetarpalCinematographyKarim KhatriEdited byAshutosh Anand VermaMusic bySurya RajkamalRelease date 20 May 2012 (2012-05-20)[1] CountryIndiaLanguageHindi Om Allah is a 2012 Indian Hindi-language film directed by Sameer Khan who was once associate director to Faisal Saif. The film stars Pakistani actress Meera and Indian sports promoter turned anchor Aushim Khetarpal.[2]...

1950 film by Elmer Clifton The Silver BanditDirected byElmer CliftonWritten byElmer CliftonProduced byRaymond FriedgenStarringSpade CooleyBob GilbertGinny JacksonCinematographyHarvey HinesEdited byRobert AdamsMusic byJohn F. HaynesProductioncompanySpade Cooley ProductionsDistributed byAstor PicturesRelease date February 20, 1950 (1950-02-20) Running time51 minutesCountryUnited StatesLanguageEnglish The Silver Bandit is a 1950 American musical Western film directed by Elmer Clif...

 

American judge Rainey BrandtAssociate Judge of the Superior Court of the District of ColumbiaIncumbentAssumed office September 16, 2019Nominated byDonald TrumpPreceded byJudith Nan MacalusoMagistrate Judge of the Superior Court of the District of ColumbiaIn officeNovember 7, 2012 – September 16, 2019 Personal detailsBornRainey Eloise Ransom[1] (1966-03-12) March 12, 1966 (age 57)[1]LaGrange, Georgia, U.S.SpouseRobert W. BrandtEducationAmerican University (B...

 

Hieronder volgt een lijst van titelkerken in Rome met een overzicht van de huidige tituli (kardinaal-priesters). Nr. Naam Afbeelding Titulus Titelkerk sinds Opmerkingen 1 Sant’Agnese fuori le mura Ruini, Camillo Camillo Ruini 5 oktober 1654 2 Sant'Agostino Ricard, Jean-Pierre Jean-Pierre Ricard 13 april 1587 3 Sant'Alberto Magno Carmo da Silva, Virgílio do Virgílio do Carmo da Silva SDB 19 november 2016 4 Santi Ambrogio e Carlo vacant sinds 5 augustus 2017 7 juni 1967 5 Sant'A...

Vârful Ineu Ineu (also Inău) is a peak in the Rodna Mountains, Romania with an elevation of 2,279 m (7,477 ft).[1] It is the second peak in height after Pietrosul Rodnei [ro] which has an elevation of 2,303 m (7,556 ft). Ineu Peak belongs to the Ineu–Lala Mixed Reservation, within the Rodna Mountains National Park. References ^ 2017 Romanian Statistical Yearbook, p. 11 47°30′39″N 24°52′41″E / 47.51083°N 24.87806°E...

 

1962 film 13 West StreetFilm posterDirected byPhilip LeacockScreenplay byBernard C. SchoenfeldRobert Presnell Jr.Based onThe Tiger Among Us (1957) by Leigh BrackettProduced byWilliam BloomAlan LaddStarringAlan LaddRod SteigerCinematographyCharles Lawton, Jr.Edited byAl ClarkMusic byGeorge DuningColor processBlack and whiteProductioncompanyLadd EnterprisesDistributed byColumbia PicturesRelease date June 6, 1962 (1962-06-06) Running time80 minutesCountryUnited StatesLanguageEngli...

 

市町村道(しちょうそんどう)とは、道路法上の道路で、市町村および特別区の区域内にあり、その地方公共団体の議会で路線が認定された道路である。管理は、その路線がある地方公共団体で行われる[1]。 概要 宮城県の岩出山町道(現大崎市道)に設置されている路線案内標識 市町村長がその市町村の区域内の部分について当該市町村議会の議決を経て路線を...

Irish politician and teacher (1872–1942) Mary MacSwineyVice President of Sinn FéinIn office1927–1933LeaderJohn J. O'KellyBrian O'HigginsPreceded byKathleen LynnSucceeded byMargaret BuckleyTeachta DálaIn officeMay 1921 – June 1927ConstituencyCork Borough Personal detailsBorn(1872-03-27)27 March 1872London, EnglandDied8 March 1942(1942-03-08) (aged 69)County Cork, IrelandOccupationPoliticianTeacherActivist Mary MacSwiney (pronounced 'MacSweeney'; Irish: Máire Nic Shuibhne...

 

American college basketball season 1988–89 UNLV Runnin' Rebels basketballBig West tournament championsBig West regular season championsNCAA tournament, Elite EightConferenceBig West ConferenceRankingCoachesNo. 14APNo. 15Record29–8 (16–2 Big West)Head coachJerry Tarkanian (16th season)Assistant coaches Tim Grgurich (8th season) Keith Starr (3rd season) Ron Ganulin (1st season) Home arenaThomas & Mack CenterSeasons← 1987–881989–90 → 1988...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!