Skip to main content

imgread

A public beta Python library for decoding JPEG, PNG and TIFF into NumPy arrays, with a Rust decoder and a statically linked libjpeg-turbo backend.

python -m pip install --pre imgread

Use a wheel on a supported platform; it needs no Rust toolchain. To require a wheel: python -m pip install --pre --only-binary=:all: imgread. A source build requires Rust 1.88 or newer, CMake, a C compiler and NASM.

from pathlib import Path
import imgread

# Path and os.PathLike[str]
rgb = imgread.load_numpy(Path("photo.jpg"))

# bytes, bytearray, memoryview or a uint8 NumPy buffer (including strided views)
bgr = imgread.load_numpy_from_bytes(Path("photo.png").read_bytes(), color="bgr")

# Choose the portable Rust decoder explicitly
rgb = imgread.load_numpy("scan.tiff", backend="image")

Array and format contract

Every successful call returns a new writable, C-contiguous numpy.ndarray of shape (height, width, 3) and dtype uint8. The default order is RGB; color="bgr" reverses the channels. Only dtype="uint8" is supported. Color, dtype, backend and limit-profile names are case-insensitive. Bytes paths are rejected; use the buffer APIs for encoded bytes. Decoding releases the GIL after taking a private input copy.

  • JPEG: baseline, progressive, grayscale and CMYK. CMYK may use the fallback decoder. Decoder rounding and chroma upsampling can produce small pixel differences between backends; bit-for-bit JPEG parity is not promised.
  • PNG: grayscale, RGB, RGBA and 16-bit input. Alpha is discarded without compositing. Grayscale is replicated into three channels. Unsigned 16-bit values are rounded to 8 bits using (value + 128) // 257.
  • TIFF: the first page only, without applying orientation. Common uncompressed, LZW and Deflate variants and little-/big-endian samples are supported. Supported encodings follow the image TIFF decoder; unsupported encodings raise errors.
  • EXIF orientation, ICC color conversion and other metadata are not applied or returned. Pixels remain in the encoded color space. Animated PNG returns its default image, not an animation.

Other formats are rejected even though the underlying Rust image dependency retains its default features in this beta.

Backends and the simple API

backend="auto" selects TurboJPEG for JPEG when compiled in and image otherwise. backend="image" always selects the Rust decoder. backend="turbojpeg" falls back to image when unavailable, incompatible with the format, or unable to decode it. A successful fallback emits RuntimeWarning. An unsuccessful decode raises an error. auto also warns if an attempted TurboJPEG decode falls back. Inspect the build with imgread.supported_backends(); official wheels include TurboJPEG.

load_numpy_simple(path, *, limits="safe") and load_numpy_simple_from_bytes(data, *, limits="safe") are JPEG-only RGB shortcuts. They use the same checked decoder and warning/fallback behavior. Non-JPEG input is always a ValueError. Python's normal warnings filters control every warning, including always, ignore and error; the library has no global deduplication.

Resource limits

All four decode functions accept the keyword-only argument limits="safe":

Budget per image Default cap
Encoded input 256 MiB
Width / height 32,768 each
Pixels 100,000,000
RGB/BGR output 512 MiB
Decoder allocation budget 512 MiB

Input size is checked before copying a Python buffer or reading a regular file. The open file is read with a bound even if it grows. Dimensions and output sizes are checked before the pixel allocation. A resource-limit failure is terminal: no fallback can retry it with another decoder.

The decoder budget is passed to image::Limits and to libjpeg-turbo's intermediate buffer memory limit. The image JPEG backend also preflights a conservative working-set bound covering padded coefficient planes, decoded pixels and row/upsampling buffers, because its upstream JPEG decoder ignores max_alloc. This applies to fallback routes too, and may reject a large JPEG even when its final pixels fit the output cap (including baseline JPEGs that need less memory). These budgets do not measure total process RSS: encoded input, output, metadata, conversion buffers, allocator overhead and concurrent calls can add to it. It is a per-image policy, not a process sandbox.

For trusted large inputs only, use limits="unlimited". This removes policy caps; checked arithmetic, address-space checks and fallible application allocations remain enabled. It makes no speed promise. Ordinary allocation pressure and upstream codec behavior can still cause errors.

Errors

Condition Exception
Invalid input type, including bytes paths TypeError
Invalid option, unsupported format or resource limit ValueError
Missing file FileNotFoundError
Permission denied PermissionError
Directory used as input IsADirectoryError
Other filesystem failure OSError subclass with OS errno
Corrupt or undecodable image RuntimeError
Successful backend fallback RuntimeWarning

Format detection uses content; for path input an extension is a last resort for identifying a damaged image. Unknown bytes raise ValueError; a recognized but corrupt image raises RuntimeError.

Beta support and stability

The release wheel matrix targets CPython 3.11–3.14, Linux x86_64 manylinux2014 (glibc 2.17+) and macOS x86_64 (10.13+) / arm64 (11.0+). Windows, Linux aarch64, musllinux, PyPy, free-threaded CPython and Python 3.15 are not supported by this beta. The 3.15 compatibility CI job is informational.

The five functions above form the beta API. Bug fixes can change rejection of malformed inputs, limits or decoder results. Intentional API changes will be recorded in release notes and beta versions; pin a version for reproducible work. The Rust crate is internal and is not published to crates.io.

Development

Use uv run for Python-facing commands. Normal builds and tests use the committed Cargo.lock and uv.lock without updating them.

uv sync --locked --no-install-project
uv run maturin develop --locked
uv run pytest python_tests -q
cargo test --locked
cargo test --locked --features turbojpeg
cargo fmt -- --check
cargo clippy --locked --all-targets --all-features -- -D warnings
uv run maturin build --release --locked --sdist
uv run twine check target/wheels/*
uv run python scripts/check_artifacts.py --allow-local target/wheels/*
uv run python scripts/update_notices.py --check

--allow-local validates local artifacts without certifying their platform tags for release. Keep maturin's configured features when building; passing --features extension-module alone overrides them and removes TurboJPEG.

License

The project uses the MIT license. Redistributed dependency notices are in THIRD_PARTY_NOTICES.md and licenses/ and are included in both wheels and sdists.

This software is based in part on the work of the Independent JPEG Group.

Metadata

Release files for imgread 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imgread 0.2.0
File Size Uploaded
imgread-0.2.0.tar.gz 123.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for imgread 0.2.0
File
imgread-0.2.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
imgread-0.2.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
imgread-0.2.0-cp314-cp314-macosx_10_13_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.13+ x86-64 Details
imgread-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
imgread-0.2.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
imgread-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
imgread-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
imgread-0.2.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
imgread-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
imgread-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
imgread-0.2.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
imgread-0.2.0-cp311-cp311-macosx_10_13_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.13+ x86-64 Details

Total release size: 14.7 MB

Release files / imgread-0.2.0.tar.gz

Download URL imgread-0.2.0.tar.gz
Size 123.8 kB
Tags Source
SHA-256 checksum
How to use checksums
90a4d77b9223fe839cf51548252b31514a88e7c37ce7d47dd623c93cc82b615f
BLAKE2b-256 checksum
How to use checksums
2c1d74a37f5b5527302d430f968ad6fdee614377d773755e8e7faaed9efc3c1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL imgread-0.2.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.3 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2837adea89a978edaec40173d471a753166e3d0579c9cef2d7bfecf39a087727
BLAKE2b-256 checksum
How to use checksums
5ee8f8ded894c9a64e9bed4084a09aed7ef8324df28c9d8893243749e3c4ca1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL imgread-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a224026210de1275124f51177833a52ad010c5737b6a27e12f3e054f92430827
BLAKE2b-256 checksum
How to use checksums
ac542fa2587511c29f80b876b9ab0b04727e12f44ae96d9c903289228d37f7cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp314-cp314-macosx_10_13_x86_64.whl

Download URL imgread-0.2.0-cp314-cp314-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.14 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
c2060dae3f4a43d215c2c5580676c963e70f26c09b6647d4dded48f2d571a637
BLAKE2b-256 checksum
How to use checksums
0a546acd3fe217c1bbe8104e40aa3c3f26ee3c70c930ccc82d482512195f4deb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL imgread-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.3 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
25c352df09f68357dafbe6347bb9a788cd53b8d6f2d350eef9fda9a451a0e471
BLAKE2b-256 checksum
How to use checksums
909d0bbbb0565a319361e0101536abe0d98887e29251f070fedef89c9298ec1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL imgread-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e64f5c44d9f80fff26fa9f963c4955e5f65d62f65387ae6e4dbb48da4f8f3a3b
BLAKE2b-256 checksum
How to use checksums
5025089ad12c9681ebec9f3352a88ca184e8031d1d08fd158b9050844f0f898d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl

Download URL imgread-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
048f5db7a7281c69768c89ba34e4190cdecc35d8d5062eb9263d9f6d5d676325
BLAKE2b-256 checksum
How to use checksums
8079f21f89220eaa3c2d3ded4c86c196bc8d590dca9a70bec9c31996ffbf49c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL imgread-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.3 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e21b647f71b1be8959194d44d4a698576d87cc0a81dc411f0bfbd2bf661b13c0
BLAKE2b-256 checksum
How to use checksums
f634454d48e396c59c8fbd5315889457b3c613c37d69765f7266ac3ea61dc4b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL imgread-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4c3e30dff7b639f61e8a672e2638a2785da3339442bb8557bed219b962c34947
BLAKE2b-256 checksum
How to use checksums
736ebbedbbb38ba45131b51b3f6e122e52a820304b4f4f4c80aa91ba8f9f5664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl

Download URL imgread-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
a7da36f8df5c883ae30f7facf33ea50bdfa1d9f500ddb1ae24654decc8a25812
BLAKE2b-256 checksum
How to use checksums
1db2f9579d4e09e5974ef1e38c4650b0c70133af5f6c2d8fd92f207639f9f7fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL imgread-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.3 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
11fde4362628a56bd0d0371dc7da2f9b408ea5404cc9b62c3ca66dbfcebda589
BLAKE2b-256 checksum
How to use checksums
e09045cca7a2a08e92d265c2d532e5961461546869b9b6d5d63e969ea7df5bb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL imgread-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4aa95869e429e6b8c6251bc5d8458d09d4f921d6375c85b171655b607f5d1ec3
BLAKE2b-256 checksum
How to use checksums
e4cac5201a9b334a1cd7ddaa2ef2417e21eafcc4a828eb6fb9b49c35ed0499cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / imgread-0.2.0-cp311-cp311-macosx_10_13_x86_64.whl

Download URL imgread-0.2.0-cp311-cp311-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.11 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
d6e197b0b98905fda36365a2519184e50d46d31b86a21430ebbd2f647af6d1ea
BLAKE2b-256 checksum
How to use checksums
4e8176f674b508442bed132f28ce15ff9df775217135b814e5b2cd909f96422e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.3.0

13 release files

0.2.1

13 release files

This release

0.2.0 This release

13 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page