Skip to main content

ioimage

ci PyPI

Read and write microscopy images — TIFF, BigTIFF, OME-TIFF, ImageJ TIFF and OME-Zarr — with one API.

  • Lazy region reads: opening an image reads only headers and metadata, and a region read touches only the pages or chunks it needs.
  • Pyramids and sharding for OME-Zarr, with bounded memory for conversion.
  • A format-independent metadata model that extracts everything a file carries (anisotropic voxel size, channels, time, objective, acquisition, the original metadata blocks verbatim) and carries it through every conversion.
  • A shared frame with iorec, which stores .rec meshes: both use the same vocabulary (coordinate_frame, axis_order, spacing, spacing_unit, source_shape, crop_offset), so a mesh and its image live in the same frame.

Licence: GPL-3.0-or-later.

Installation

pip install ioimage

The core depends on numpy and tifffile only. OME-Zarr needs the zarr extra (zarr-python ≥ 3.2), and compressed TIFF codecs beyond zlib need the codecs extra (imagecodecs):

pip install "ioimage[zarr,codecs]"

Python ≥ 3.12.

Usage

Python

import ioimage

# open lazily: only headers and metadata are read
with ioimage.open("stack.ome.zarr") as img:  # or stack.tif / stack.ome.tif
    img.shape, img.dtype, img.axes, img.levels  # (1024, 2048, 2048) uint16 'zyx' 3
    img.meta.spacing, img.meta.spacing_unit  # (2.0, 0.325, 0.325) 'micrometer' — or None, never a default
    crop = img.read(region=(slice(100, 356), slice(0, 512), slice(512, 1024)))  # only those chunks are read
    low = img.read(level=2)  # a pyramid level
    one = img.read(channel=0, timepoint=3)  # on 4-D / 5-D images: selects and drops the axis
    crop, crop_meta = img.read_with_metadata(region=(slice(100, 356),))  # metadata of the crop (origin, crop_offset)

array, meta = ioimage.read("stack.tif")  # whole image in one call

# write: the format follows the suffix, or format="tiff" | "imagej" | "ome-tiff" | "ome-zarr"
ioimage.write("out.ome.zarr", array, meta, chunks=(64, 256, 256), shards=(256, 1024, 1024), levels=3)
ioimage.write("out.ome.tif", array, meta)
ioimage.convert("in.tif", "out.ome.zarr", levels=3)  # streamed, bounded memory

# the frame shared with iorec
iorec.save_rec("mesh.rec", points, triangles, labels, metadata=crop_meta.to_iorec())

Command line

ioimage info stack.ome.zarr            # shape, dtype, axes, levels, chunks, metadata summary
ioimage meta stack.ome.tif --json      # the full structured metadata (add --raw for the raw blocks)
ioimage convert in.tif out.ome.zarr --chunks 64,256,256 --shards 256,1024,1024 --levels 3

Metadata

ImageMetadata holds, in array-axis order: axes (a subset of tczyx), shape, dtype, spacing per space axis with spacing_unit, origin, time_interval/timestamps, channels (name, colour, excitation and emission wavelengths), objective (magnification, numerical aperture, immersion, refractive index), acquisition (date, instrument, detector, software, exposure), significant_bits, the iorec frame keys, and raw: the original OME-XML, ImageJ description, TIFF tags, vendor blocks and NGFF attributes, verbatim.

Rules: missing metadata stays missing (spacing is None, never a guessed value); anisotropic spacing is carried exactly, never resampled; a crop or a pyramid level updates the derived fields (shape, origin, spacing, crop_offset, source_shape); when a target format cannot hold a field, write warns (MetadataDropped) and records the list in the output (dropped_fields).

Target holds everything? what is dropped
OME-Zarr 0.5 yes (structured fields as attributes, OME-XML in OME/METADATA.ome.xml) —
OME-TIFF yes (standard OME-XML elements plus MapAnnotations for the raw blocks and the frame) —
ImageJ TIFF partly origin, channel colours and wavelengths, raw blocks other than ImageJ's
plain TIFF structured fields (JSON description) raw blocks

Development

Tooling: uv, just, ruff, ty, pytest, pre-commit, Sphinx.

uv sync                      # dev group: tests, ruff, ty, sphinx
just lint && just typecheck && just test
just test -m slow            # the large-stack memory test (writes an 8 GiB-equivalent store in a temp folder)
IOIMAGE_REFERENCE_DATA=/path/to/reference_data just test -m reference   # optional comparison with scikit-image (layout in tests/test_reference_data.py)

See CONTRIBUTING.md before opening a pull request. To cite ioimage, see CITATION.cff.

Metadata

Release files for ioimage 0.1.3

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

Source distribution (sdist)

Source distribution for ioimage 0.1.3
File Size Uploaded Provenance Actions
ioimage-0.1.3.tar.gz 365.2 kB Without provenance Details for ioimage-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ioimage 0.1.3
File Interpreter ABI Platform Actions
ioimage-0.1.3-py3-none-any.whl Python 3 none any Details for ioimage-0.1.3-py3-none-any.whl

Total release size: 425.9 kB

Release files / ioimage-0.1.3.tar.gz

Download URL ioimage-0.1.3.tar.gz
Size 365.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4213f3c191555770358e135ef4fa540aa885b8709fe27ed2c6077d15bf697c34
BLAKE2b-256 checksum
How to use checksums
d2cc813cf5a9bcc54c6292cdc8cd65d94ef271608e848056e6210f67b9f79770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / ioimage-0.1.3-py3-none-any.whl

Download URL ioimage-0.1.3-py3-none-any.whl
Size 60.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
105c5bcd795d0c911cac8d49c5922f7800cb50d75887e35786b20089956a7249
BLAKE2b-256 checksum
How to use checksums
d70dfd7d52aaab4d42d13fd729ea91568b6806c0a76aca4be6952cfbe7cfba6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for ioimage 0.1.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

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