Skip to main content

A Python QOI encoder/decoder.

Project description

QOI Library

A Python library for encoding and decoding QOI (Quite OK Image) files. QOI is a lossless image compression format known for its simplicity and speed.

Features

Encode: Convert pixel data (RGB or RGBA) to .qoi format. Decode: Convert .qoi files back to raw pixel data. Convenient load/save functions for file I/O. Pure Python implementation—easy to read or modify.

What is QOI?

QOI (Quite OK Image) is a fast, lossless image format originally developed by Dominic Szablewski (phoboslab). It uses a simple run-length and index-based compression method and requires no external dependencies to encode/decode. Despite being relatively new, QOI has gained popularity due to its ease of implementation and often excellent speed.

Learn more about QOI in the official QOI repository.

Installation

You can install this library from PyPI:

pip install py-qoi-encoder

Quick Usage

Below is a minimal example using Pillow to handle PNG images and converting them to .qoi:

from PIL import Image
import py-qoi-encoder

# Load an image (PNG, JPG, etc.) via Pillow
img = Image.open("example.png").convert("RGBA")
width, height = img.size
pixels = list(img.getdata())  # RGBA tuples

# Encode pixel data to QOI bytes, then write to file
qoi_data = my_qoi_lib.encode(pixels, width, height, channels=4, colorspace=0)
with open("output.qoi", "wb") as f:
    f.write(qoi_data)

# Decode the QOI file back to raw pixel data
w, h, c, decoded_pixels = my_qoi_lib.load_qoi("output.qoi")

# Convert the decoded pixels back to a Pillow image and save
decoded_img = Image.new("RGBA", (w, h))
decoded_img.putdata(decoded_pixels)
decoded_img.save("decoded.png")

Example

For more example check out the examples folder

Requirements

Python 3.7+ (Optional) Pillow for loading/saving PNG images in the examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_qoi_encoder-0.1.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_qoi_encoder-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file py_qoi_encoder-0.1.2.tar.gz.

File metadata

  • Download URL: py_qoi_encoder-0.1.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for py_qoi_encoder-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7c0e7e2481a7cb5cae96102411b396c895f6bf170447d0cc741440f6c2d28393
MD5 ec2b53e2575cdad162fc94db1d12d45f
BLAKE2b-256 c0ff3d7502da1781eedfcda8a7ee68668091621616e2f8c8a5e3ca9fb6877d02

See more details on using hashes here.

File details

Details for the file py_qoi_encoder-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_qoi_encoder-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for py_qoi_encoder-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3e1dd576f430ee6ec03e41cc079c83588ecab8425b5b02bed863313852c45f
MD5 6e91c2b97c44774eb19455fc006582ed
BLAKE2b-256 e3b7ba64bf8e8cc7c1e9d4a44bb515ee98cac60699f9c7aa77dc2d88ad755375

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page