GitHub - dragly/pyroexr: A Python wrapper around the Rust exr crate (original) (raw)

pyroexr

PyPI Downloads

This is a minimal Python wrapper around the Rust exr crate, which provides fast loading of OpenEXR files.

Note that this project only supports the functionality we currently need ourselves. For instance, the package assumes you want to load the entire file into memory and that there is only one layer in the file. I have no current plans to extend it further, but contributions are of course welcome.

Installation

The package can be installed directly from PyPI:

python -m pip install pyroexr

Usage

A file can be opened and its channels printed as follows:

import pyroexr

image = pyroexr.load("Ocean.exr") print("Channels", image.channels())

Each channel can be accessed as a NumPy array, for instance to plot it in Matplotlib:

import matplotlib.pyplot as plt plt.imshow(image.channel("B")) plt.show()

Ocean output

Development

If you want to develop this package locally, use the maturin tool to build the Rust code and install the Python package in your current environment:

You can also use the maturin tool to build the wheels or publish the package. See the maturin documentation for more details.