enum

class openexr_tools.enum.ImageCodec(value)[source]

Bases: Enum

Legal EXR image codecs.

Includes:

  • B44

  • B44A

  • DWAA

  • DWAB

  • PIZ

  • PXR24

  • RLE

  • UNCOMPRESSED

  • ZIP

  • ZIPS

B44 = ('b44', 6)
B44A = ('b44a', 7)
DWAA = ('dwaa', 8)
DWAB = ('dwab', 9)
PIZ = ('piz', 4)
PXR24 = ('pxr24', 5)
RLE = ('rle', 1)
UNCOMPRESSED = ('uncompressed', 0)
ZIP = ('zip', 3)
ZIPS = ('zips', 2)
__init__(string, exr_code)[source]
Parameters:
  • string (str) – String representation of codec.

  • exr_code (int) – EXR compression code.

static from_exr_code(code)[source]

Constructs a ImageCodec instance from a given EXR code.

Parameters:

code (int) – EXR compression code.

Raises:
  • EnforceError – If value given is not an integer.

  • EnforceError – If no ImageCodec type can be found for given code.

Returns:

ImageCodec instance.

Return type:

ImageCodec

static from_string(string)[source]

Constructs a ImageCodec instance from a given string.

Parameters:

string (int) – ImageCodec string.

Raises:
  • EnforceError – If value given is not a string.

  • EnforceError – If no ImageCodec type can be found for given string.

Returns:

ImageCodec instance.

Return type:

ImageCodec

tools

openexr_tools.tools.clean_exr_metadadata(image, metadata)[source]

Uses given image and metadata dictionary to create EXR metadata for use in writing EXRs.

Parameters:
  • image (numpy.NDArray) – Image.

  • metadata (dict) – Metadata dictionary.

Returns:

Clean metadata.

Return type:

dict

openexr_tools.tools.read_exr(fullpath)[source]

Reads an OpenEXR image file.

Parameters:

fullpath (str or Path) – Image file path.

Raises:

IOError – If given filepath is not an EXR file.

Returns:

Image and metadata.

Return type:

tuple[numpy.NDArray, dict]

write_exr(fullpath, image, metadata, codec=<ImageCodec.PIZ>
write_exr  string: piz
write_exrexr_code: 4)

Writes image data and metadata as EXR to given file path.

Parameters:
  • fullpath (str or Path) – Path to EXR file.

  • image (numpy.NDArray) – Image data.

  • metadata (dict) – Dictionary of EXR metadata.

  • codec (ImageCodec, optional) – Image codec. Default: ImageCodec.PIZ.

Raises:

TypeError – If image is not float16 or float32.

Return type:

None