Skip to main content

Minimal, standalone OpenEXR reader for single-part, uncompressed scan line files.

Project description

example workflow

minexr

minexr is a standalone, fast Python OpenEXR reader for single-part, uncompressed scan-line files. It is compatible with .exr files produced by Blender.

Assumptions

minexr makes a couple of assumptions about the .exr file to be read:

  1. single-part files with arbitrary number of channels,
  2. no pixel data compression, and
  3. equal channel types (HALF, FLOAT, UINT).

These assumptions allow us to efficiently parse and read the .exr file. In particular we gain constant offsets between scan lines which allows us to read the entire image in (H,C,W) format without copying.

Usage

The following is taken from example.py

import minexr

with open('file.exr', 'rb') as fp:
        reader = minexr.load(fp)
        rgba = reader.select(['Color.R','Color.G','Color.B','Color.A'])
        # a HxWx4 np.array with dtype based on exr type.
        ...

Full example.py loads the following images

which were previously rendered using Blender/EEVEE cube.blend.

Runtime

The following timings are produced by bench.py by repeatable reading an RGBA image from an .exr file. Timings include file and numpy operations.

Module [sec/image] Note
OpenEXR 1.3.2 0.020 with channel concatenate
OpenEXR 1.3.2 0.015 without channel concatenate
minexr 0.004 with channel concatenate

Install

Either via pip

pip install minexr

Or clone this repository and invoke

pip install -e .

Tests

To run the tests

pytest

Blender support

Use a FileOutput node in Blender's compositor to export .exr files. Make sure to select OpenEXR MultiLayer format and set CODEC to None as shown in the following image. Color Depth can be chosen as required.

When unsure about which channels are being written, you can inspect the file content as follows
import minexr

with open('file.exr', 'rb') as fp:
        reader = minexr.load(fp)
        print(reader.channel_names)
        # ['Color.R','Color.G','Color.B', ...]
        print(reader.attrs)
        # Dictionary of all OpenEXR header attributes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minexr-1.0.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file minexr-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: minexr-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for minexr-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cb9b46e9a31ad861316c6af5e7023bfe8376b083aeebd81bc4729e66f2b08ad9
MD5 d3d82b54963c5f728c75d7f835ff1097
BLAKE2b-256 8c6a1c693a98f3caee8a4de0f308f58fd85b08ac6d00dca518456e898d434169

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page