Skip to main content

A simpler wrapper around qoi (https://github.com/phoboslab/qoi)

Project description

QOI

A simple Python wrapper around qoi, the "Quite OK Image" format.

Install

pip install qoi

Example

import numpy as np
import qoi

# Get your image as a numpy array (OpenCV, Pillow, etc. but here we just create a bunch of noise)
rgb = np.random.randint(low=0, high=255, size=(224, 244, 3)).astype(np.uint8)

# Write it:
_ = qoi.write("/tmp/img.qoi", rgb)

# Read it and check it matches (it should, as we're lossless)
rgb_read = qoi.read("/tmp/img.qoi")
assert np.array_equal(rgb, rgb_read)

# Likewise for encode/decode to/from bytes:
bites = qoi.encode(rgb)
rgb_decoded = qoi.decode(bites)
assert np.array_equal(rgb, rgb_decoded)

Developing

git clone --recursive https://github.com/kodonnell/qoi/
USE_CYTHON=1 pip install -e .[dev]
pytest .

We use cibuildwheel to build all the wheels, which runs in a Github action. If you want to check this succeeds locally, you can try (untested):

cibuildwheel --platform linux .

Finally, when you're happy, submit a PR.

Publish

This currently is all automatic, and just needs a new tag pushed to Github in the vX.X.X format.

TODO:

  • Fix the cython project structure. I had to try a bunch of things to get the version (from setuptools_scm in) but it feels very fragile. I'd prefer everything in an __init__.py (defining imports and __all__ etc.) but that doesn't seem to work. I also don't get why this is working as it is - I feel like there's some package/namespace magic going on (e.g. the files being called qoi.p* is important), but haven't been able to fix it. See maybe https://stackoverflow.com/questions/33555927/cython-relative-cimport-beyond-main-package-is-not-allowed ? Also, I think our use of src might be tripping us up (i.e. still valid, but needs more obscure fixing than just out-of-the-box).
  • Get cp310-win32 building ...
  • Create a qoi CLI
  • Add some benchmarks and compare with qoi
  • Automatically create release on github when push a tag v*?
  • setuptools_scm_git_archive?
  • Get cibuildwheels to do a build without --wheel option to ensure the source distribution is good.

Discussion

Wrap or rewrite?

For now, this is just a simple wrapper. We'll leave the original project to do all the hard work on performance etc., and also maintaining (or not) compatibility or adding new features etc. We make no claims to do any more than that - we're basically just porting that C functionality to (C)Python.

On the name

For now, let's rock with qoi because

  • We're already in python, and the py in pyqoi seems redundant. For what it's worth, 3 < 5.
  • pyqoi seems like a good name for a python-only version of QOI (useful for pypy etc.), which this isn't.
  • qoi is generally new so let's not overthink it for now. We can always rename later if needed.

What's up with ./src?!

See here and here. I didn't read all of it, but yeh, import qoi is annoying when there's also a folder called qoi.

USE_CTYHON=1?

See here. Fair point.

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

qoi-0.0.8.tar.gz (69.4 kB view hashes)

Uploaded Source

Built Distributions

qoi-0.0.8-cp310-cp310-win_amd64.whl (33.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

qoi-0.0.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (149.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

qoi-0.0.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (143.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

qoi-0.0.8-cp310-cp310-macosx_10_9_x86_64.whl (33.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

qoi-0.0.8-cp39-cp39-win_amd64.whl (33.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

qoi-0.0.8-cp39-cp39-win32.whl (28.6 kB view hashes)

Uploaded CPython 3.9 Windows x86

qoi-0.0.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (148.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

qoi-0.0.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (142.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

qoi-0.0.8-cp39-cp39-macosx_10_9_x86_64.whl (33.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

qoi-0.0.8-cp38-cp38-win_amd64.whl (33.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

qoi-0.0.8-cp38-cp38-win32.whl (28.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

qoi-0.0.8-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (155.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

qoi-0.0.8-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (149.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

qoi-0.0.8-cp38-cp38-macosx_10_9_x86_64.whl (32.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

qoi-0.0.8-cp37-cp37m-win_amd64.whl (33.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

qoi-0.0.8-cp37-cp37m-win32.whl (28.3 kB view hashes)

Uploaded CPython 3.7m Windows x86

qoi-0.0.8-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

qoi-0.0.8-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (134.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

qoi-0.0.8-cp37-cp37m-macosx_10_9_x86_64.whl (32.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

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