2
1
Fork
You've already forked zqoi
0
Qoi image decoder and encoder written in Zig
  • Zig 94.2%
  • Shell 4.1%
  • Nix 1.7%
2026年05月27日 18:04:29 +02:00
benchmark Fix benchmark deps 2026年05月22日 09:39:24 +02:00
example Bump zig to 0.16 2026年04月25日 17:15:12 +02:00
src Move header check 2026年04月25日 20:57:30 +02:00
.gitignore Bump zig to 0.16 2026年04月25日 17:15:12 +02:00
build.zig Bump zig to 0.16 2026年04月25日 17:15:12 +02:00
build.zig.zon Move header check 2026年04月25日 20:57:30 +02:00
flake.lock Bump zig to 0.16 2026年04月25日 17:15:12 +02:00
flake.nix Fix benchmark deps 2026年05月22日 09:39:24 +02:00
image.qoi Update tests and example 2025年12月30日 12:55:41 +01:00
LICENSE Bump license year 2026年02月01日 16:26:45 +01:00
README.md Remove warning 2026年05月27日 18:04:29 +02:00

Zqoi

QOI decoder/encoder written in pure Zig. Optimized for decoding speed.

Using

You will need:

  • Zig compiler 0.16.0

Fetch:

zig fetch --save git+https://github.com/Pivok7/zqoi

In build.zig:

constzqoi=b.dependency("zqoi",.{.target=target,.optimize=optimize,}).module("root");exe.root_module.addImport("zqoi",zqoi);

Example:

conststd=@import("std");constzqoi=@import("zqoi");pubfnmain(init:std.process.Init)!void{constallocator=init.gpa;constio=init.io;// Load and save file{varimg=tryzqoi.Image.fromFilePath(allocator,io,"../image.qoi");deferimg.deinit(allocator);tryimg.toFilePath(io,"copy.qoi");}// Manually create image{varimg=zqoi.Image{.width=1024,.height=1024,.pixels=undefined,.format=.r8g8b8a8_srgb,};img.pixels=tryallocator.alloc(zqoi.Rgba,img.width*img.height);deferallocator.free(img.pixels);for(img.pixels,0..)|*pixel,i|{pixel.*=zqoi.Rgba{.r=@as(u8,@intCast(i%256)),.g=@as(u8,@intCast(i%128)),.b=@as(u8,@intCast(i%64)),.a=255,};}tryimg.toFilePath(io,"generated.qoi");}}

Speed

You can run benchmarks yourself by following the instructions in the 'benchmark' directory.

Benchmarks performed on the images from https://qoiformat.org/benchmark/

CPU: AMD Ryzen 7 5700X

The results:

Encoding zqoi reference
textures_plants 3.60ms 4.2ms
screenshot_game 2.54ms 2.6ms
textures_pk02 1.82ms 1.8ms
photo_kodak 2.59ms 2.6ms
textures_pk01 0.66ms 0.7ms
icon_512 0.49ms 0.7ms
photo_tecnick 10.02ms 10.0ms
icon_64 0.01ms 0.0ms
textures_photo 6.45ms 6.1ms
textures_pk 0.33ms 0.3ms
screenshot_web 15.27ms 23.0ms
photo_wikipedia 7.71ms 7.6ms
pngimg 6.18ms 7.4ms
total 1.99ms 2.1ms
Decoding zqoi reference
textures_plants 2.07ms 2.7ms
screenshot_game 1.69ms 2.1ms
textures_pk02 1.23ms 1.4ms
photo_kodak 1.58ms 2.0ms
textures_pk01 0.41ms 0.5ms
icon_512 0.31ms 0.4ms
photo_tecnick 6.14ms 7.6ms
icon_64 0.01ms 0.0ms
textures_photo 3.97ms 5.1ms
textures_pk 0.18ms 0.2ms
screenshot_web 8.88ms 20.4ms
photo_wikipedia 4.62ms 5.8ms
pngimg 3.63ms 5.8ms
total 1.24ms 1.7ms