Skip to content

Python: Writing EXR header fails with float32-ndarray attributes of length >=3 #2054

@vjankijevic

Description

@vjankijevic

Trying to copy header data over from one EXR file to another, I encountered the following error:

RuntimeError: unrecognized type of attribute 'com.arri.camera.LookCdlOffset': type=ndarray value=[0. 0. 0.] dtype=float32

Below is a minimal example of code producing the issue, with example files.zip attached.

import OpenEXR as exr

# Copy header from file_two to file_one and save new file as file_three.
with exr.File("/tmp/file_one.exr") as file_one:
    output_header = file_one.header()

    with exr.File("/tmp/file_two.exr") as file_two:

        for key, value in file_two.header().items():
            if key not in (
                "displayWindow",
                "dataWindow",
                "pixelAspectRatio",
                "screenWindowCenter",
                "screenWindowWidth",
                "lineOrder",
                "compression",
                "channels",
                "tiles",
                "view",
                "name",
                "type",
                "version",
                "chunkCount",
                "maxSamplesPerPixel",
            ):
                output_header[key] = value

    with exr.File(output_header, file_one.channels()) as output_file:
        output_file.write("/tmp/file_three.exr")

The workaround is to convert the array to a list with value.tolist().

Tested with Python 3.10.14, OpenEXR v3.3.3 and numpy 2.0.0 on macos and linux/rocky9.4

Thank you,
Vladimir

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions