PyEXR
A simple EXR IO-library for Python that simplifies the use of OpenEXR.
Installation
pip install pyexr
Reading
Simple files
import pyexr
with pyexr.open("color.exr") as file:
file.channels # [R, G, B]
file.width # 1280
file.height # 720
file.channel_precision["R"] # pyexr.FLOAT
img = file.get() # (720,1280,3) np.float32 array
img = file.get(precision=pyexr.HALF) # (720,1280,3) np.float16 array
red = file.get("R") # (720,1280,1) np.float32 array
red = file.get("R", precision=pyexr.HALF) # (720,1280,1) np.float16 array
Fat / Multi-channel EXRs
import pyexr
with pyexr.open("multi-channel.exr") as file:
file.channels # [R, G, B, A, Variance.R, Variance.G, Variance.B]
file.width # 1280
file.height # 720
all = file.get() # (720,1280,7) np.float32 array (R,G,B,A,Var..)
var = file.get("Variance") # (720,1280,3) np.float32 array
col = file.get("default") # (720,1280,4) np.float32 array (R,G,B,A)
file.channel_map['default'] # ['R','G','B','A']
var_r = file.channel("Variance.R") # (720,1280,3) np.float32 array
One line reading
import pyexr
# 'color.exr' contains R, G, B
img = pyexr.read("color.exr") # (720,1280,3) np.float32 array
img = pyexr.read("color.exr", precision=pyexr.HALF) # (720,1280,3) np.float16 array
# 'multi-channel.exr' contains R, G, B, A, Variance.R, Variance.G, Variance.B
all = pyexr.read("multi-channel.exr") # (720,1280,7) np array
col = pyexr.read("multi-channel.exr", "default") # (720,1280,4) np array
var = pyexr.read("multi-channel.exr", "Variance") # (720,1280,3) np array
col, var = pyexr.read("multi-channel.exr", ["default", "Variance"])
col, var = pyexr.read("multi-channel.exr", ["default", "Variance"], precision=pyexr.HALF)
col, var = pyexr.read("multi-channel.exr", ["default", "Variance"], precision=[pyexr.HALF, pyexr.FLOAT])
Writing
You can write a matrix to EXR without specifying channel names. Default channel names will then be used:
| # columns | default |
|---|---|
| 1 channel | Z |
| 2 channels | X, Y |
| 3 channels | R, G, B |
| 4 channels | R, G, B, A |
import pyexr
depth # (720,1280) np.float16 array
color # (720,180,3) np.float32 array
normal # (720,180,3) np.float32 array
pyexr.write("out.exr", depth) # one FLOAT channel: Z
pyexr.write("out.exr", color) # three FLOAT channels: R, G, B
pyexr.write("out.exr", normal,
channel_names=['X','Y','Z']) # three FLOAT channels: X, Y, Z
Writing Fat EXRs
import pyexr
depth # (720,1280) np.float16 array
color # (720,180,3) np.float32 array
variance # (720,180,3) np.float32 array
data = {'default': color, 'Depth': depth, 'Variance': variance} # default is a reserved name
pyexr.write("out.exr", data) # channels R, G, B, Depth.Z, Variance.(R,G,B)
# Full customization:
pyexr.write(
"out.exr",
data,
precision = {'default': pyexr.HALF},
channel_names = {'Depth': ['Q']}
) # channels R, G, B, Depth.Q, Variance.R, Variance.G, Variance.B
Metadata
Release files for pyexr 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyexr-0.5.0.tar.gz | 7.2 kB | Without provenance | Details for pyexr-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyexr-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pyexr-0.5.0-py3-none-any.whl |
Total release size: 14.1 kB
Release files / pyexr-0.5.0.tar.gz
| Download URL | pyexr-0.5.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
674610760808ca4ee088bfdeb6bd338deb9f4bcf5a9e8adc6567ed747e48f98d
|
|
BLAKE2b-256 checksum How to use checksums |
534444d6da1bb4dc996097518decebd274ae48e174ce81578cdf3c21e7a8e800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.8 Linux/6.8.0-1020-azure
|
Release files / pyexr-0.5.0-py3-none-any.whl
| Download URL | pyexr-0.5.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7c509f038950dce223be063a8ebf28e891eafd0ac9e7fb1b470c4e02898f0de
|
|
BLAKE2b-256 checksum How to use checksums |
2bd150e0e1a4c153b40cfb8f814abf9e47ae63c2ed280b308d977d23c4496edb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.8 Linux/6.8.0-1020-azure
|
Security for pyexr 0.5.0
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.