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.
The package can be installed directly from PyPI:
python -m pip install pyroexr
A file can be opened and its channels printed as follows:
import pyroexr
image = pyroexr.load("Ocean.exr")
print("Channels", image.channels())
Channels ['B', 'G', 'R']
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()
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:
maturin develop
You can also use the maturin tool to build the wheels or publish the package. See the maturin documentation for more details.