Python implementation of QOI encoder and decoder
QOI format: https://qoiformat.org/
git clone https://github.com/adusachev/QOI-image-compression.gitpython3 -m venv venv
source venv/bin/activatepython3 setup.py installmkdir <PATH_TO_REPO>/qoi_images- Encode: convert png image to qoi image
 
from qoi_compress import qoi_encoder, qoi_decoder
png_file = "./png_images/doge.png"
qoi_file = "./qoi_images/doge.qoi"  # where to save qoi image
qoi_encoder.run_encoder(png_file, qoi_file)- Decode: import .qoi file into numpy array
 
from qoi_compress import qoi_encoder, qoi_decoder
qoi_file = "./qoi_images/doge.qoi"
img_decoded, time_elapsed = qoi_decoder.run_decoder(qoi_file)
print(img_decoded)save decoded image as png:
import numpy as np
from PIL import Image
im = Image.fromarray(img_decoded.astype(np.uint8))
im.save("img_decoded.png")- Test: encode image 
png_fileand save it asqoi_file, then decodeqoi_fileand compare decoded qoi image with original png image 
from qoi_compress.main import run_single_experiment
png_file = "./png_images/doge.png"
qoi_file = "./qoi_images/doge.qoi"
run_single_experiment(png_file, qoi_file)| Image size | Encoding time | Decoding time | Compression ratio | 
|---|---|---|---|
| 460x460 | 0.7 sec | 0.3 sec | 2.2 | 
| 1920x1080 | 5.5 sec | 2.5 sec | 2.56 | 
| 3840x2400 | 42 sec | 19 sec | 1.83 | 
Add support for RGBA images