Skip to main content

micro-reader-codecs

Native image decoders for micro-reader.

micro-reader-codecs holds the Rust decoders that micro-reader uses to read compressed microscopy data. It is a separate package so that micro-reader itself stays pure Python.

You normally don't need to install it yourself. It is installed automatically with:

pip install micro-reader

It has no Python dependencies.

How it works

  • Every decoder writes straight into a buffer you provide, such as a NumPy array.
  • Decoders run without holding Python's lock, so micro-reader's thread pool can decode on all cores.
  • Baseline JPEG, JPEG 2000 and JPEG XL decode on one thread each. micro-reader already decodes many tiles at once, and threads inside the codec would compete for the same cores.

Decoders

Function Codec Rust crate
zstd_decompress_into zstd zstd (libzstd)
lz4_block_decompress_into LZ4 block lz4_flex
lzf_decompress_into LZF (h5py's HDF5 filter) own
lzw_decode_into LZW, TIFF variant weezl
zlib_decompress_into zlib / deflate libdeflater (libdeflate)
packbits_decode_into PackBits own
jpeg_decode_into JPEG: baseline, extended, progressive, arithmetic; 8- and 12-bit; lossless (2-16 bit); NDPI's stripes libjpeg-turbo 3.2.1 with its SIMD (C, vendored)
JPEG libjpeg-turbo declines or warns about (4 components, damaged data) own (following libjpeg-turbo), then jpeg-decoder
jpegxr_decode_into JPEG XR (Zeiss slide scans), colour as R, G, B; as imagecodecs decodes it jxrlib (Microsoft, C, vendored)
jxl_decode_into JPEG XL jxl-oxide
jpeg2k_decode_into JPEG 2000 (J2K, JP2), also YCbCr with subsampled colour (e.g. Aperio slides) jpeg2k (OpenJPEG)
png_decode_into PNG png
webp_decode_into WebP, lossless and lossy image-webp
unpack_bits_into packed samples, 1 to 32 bit own
eer_decode_into EER (Falcon cryo-EM movies) own, ported from imagecodecs (BSD-3)

Reading large blocks in parts

Some compressed blocks are too large to decode as a whole. These decoders read only part of a block:

  • jpeg2k_decode_area_into and jxl_decode_area_into decode only the rectangle you ask for.
  • StreamDecoder decodes one compressed block of a file as a stream and keeps only the bytes you ask for. It supports zlib, deflate, LZW, zstd, PackBits, PNG rows and uncompressed data. Each read continues where the last one stopped.
  • BlockIndex keeps checkpoints of a deflate block. Several StreamDecoders can share one, so jumping back in the block resumes from the nearest checkpoint instead of the start.

libjpeg-turbo and jxrlib are the libraries imagecodecs uses, called the same way, so the pixels are imagecodecs' (tests/test_c_decoders.py) and so is the speed: on six NDPI slides 0.89-1.42x tifffile + imagecodecs; on five Zeiss JPEG XR scans a tile decodes at 0.90-0.95x imagecodecs, whole reads within noise of it (2026-11-10).

Not included yet

LERC, CCITT fax, float24 and a few rarer TIFF codecs still go through imagecodecs:

pip install "micro-reader[codecs]"

Building

The Rust toolchain is pinned in rust-toolchain.toml. Building also needs CMake and, on x86, NASM, for libjpeg-turbo's SIMD (build.rs; ARM's NEON needs no assembler). To build and install into the active virtual environment:

maturin develop --release

Without NASM the build still works, with plain C JPEG decoding and a warning; MICRO_READER_REQUIRE_SIMD=1 (the wheel builds) makes it an error. NASM=<path> names the assembler when it is not on PATH. --no-default-features leaves out both C libraries (features libjpeg-turbo, jxrlib): micro-reader then uses its own JPEG decoder and imagecodecs for JPEG XR.

Tests

The tests live in the repository's tests/ folder:

  • test_codecs.py
  • test_czi_codecs.py
  • test_tiff_codecs.py
  • test_jpeg_exact.py
  • test_c_decoders.py
  • test_memory_limit.py

They compare these decoders with independent reference decoders, bit for bit.

License

MIT

The bundled crates and C libraries (libzstd, libdeflate, OpenJPEG, libjpeg-turbo, jxrlib) are MIT, Apache-2.0, BSD or Zlib licensed. libjpeg-turbo, and micro-reader's own JPEG decoder that follows it, carry the IJG and BSD licences: this software is based in part on the work of the Independent JPEG Group. All notices ship in every wheel as THIRD_PARTY_LICENSES.txt.

Whenever Cargo.lock changes, regenerate it with:

python scripts/third_party_licenses.py

Metadata

Release files for micro-reader-codecs 0.0.5

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

Source distribution (sdist)

Source distribution for micro-reader-codecs 0.0.5
File Size Uploaded Provenance Actions
micro_reader_codecs-0.0.5.tar.gz 1.7 MB With provenance Details for micro_reader_codecs-0.0.5.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for micro-reader-codecs 0.0.5
File Actions
micro_reader_codecs-0.0.5-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for micro_reader_codecs-0.0.5-cp311-abi3-win_amd64.whl
micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
micro_reader_codecs-0.0.5-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for micro_reader_codecs-0.0.5-cp311-abi3-macosx_11_0_arm64.whl
micro_reader_codecs-0.0.5-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for micro_reader_codecs-0.0.5-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 11.7 MB

Release files / micro_reader_codecs-0.0.5.tar.gz

Download URL micro_reader_codecs-0.0.5.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
8829b5e4b64038884edb5e9ac938578690d113a08dab1cd7aa87f68bac8fdd9c
BLAKE2b-256 checksum
How to use checksums
25d66e1cf0a73fc0e63d1337c1664f39edcc10974ba6f9ac9cdb9892e41189cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / micro_reader_codecs-0.0.5-cp311-abi3-win_amd64.whl

Download URL micro_reader_codecs-0.0.5-cp311-abi3-win_amd64.whl
Size 1.9 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0e1fb9928be01483fd629bca918c4cde64aa692410ce03723b2030989fdfc56b
BLAKE2b-256 checksum
How to use checksums
1e6f7a3da883eb0c8a2ff5c8864db71066f1ab706dc1d40a0c9dd24557bbb6a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5d487ada3e7b6edb6531fc03a38e1e2fc7ff6c2e647137531311c8e7e1c9cc60
BLAKE2b-256 checksum
How to use checksums
cd0be1b799c02f51d8dbcdf6e95199b31ec229f852cf49048d974d5788e74293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL micro_reader_codecs-0.0.5-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.9 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5b0ef022252702469d3b82d98a72a2b29c3cd4a18854d8177118a7b92378c1ca
BLAKE2b-256 checksum
How to use checksums
f15d65fbba92d09a3422a27e6a3b4ffcedbc8d0ba4d7d1813dc2d02a41f8b435
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / micro_reader_codecs-0.0.5-cp311-abi3-macosx_11_0_arm64.whl

Download URL micro_reader_codecs-0.0.5-cp311-abi3-macosx_11_0_arm64.whl
Size 1.9 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
473b7d0fd926eb300b844f47a32f328dd45b43de84ee542687bac1466471c2aa
BLAKE2b-256 checksum
How to use checksums
16812c4d597f1f125ffd917e59ce1edcbb80f515e644da4502f766364c1657f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / micro_reader_codecs-0.0.5-cp311-abi3-macosx_10_12_x86_64.whl

Download URL micro_reader_codecs-0.0.5-cp311-abi3-macosx_10_12_x86_64.whl
Size 2.1 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6a1ce4ee03db73eba3d3544449251ce1a935f8e65dd57a946f108f5e974d8f5a
BLAKE2b-256 checksum
How to use checksums
90868ef6fbffcede8bc1b85e2058065676e3a1b2feae39dc37c4c56dd8c138af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for micro-reader-codecs 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for micro_reader_codecs-0.0.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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