Skip to content

feat(openexr): Follow CIF for color interop ID in multi-part files - #5422

Draft
brechtvl wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
brechtvl:exr-multipart-colorspace
Draft

feat(openexr): Follow CIF for color interop ID in multi-part files#5422
brechtvl wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
brechtvl:exr-multipart-colorspace

Conversation

@brechtvl

Copy link
Copy Markdown
Contributor

Description

On read, a part without a colorInteropID now gets it from the first part, if there is any. There is no validation, EXR files that do not follow the CIF recommendation are still accepted.

On write, give an error when the colorInteropID in later parts is different than the first part, except if is missing or set to "data". Upcoming versions of OpenEXR will throw an exception in this case, this applies the same logic for existing versions of OpenEXR already.

Note this means writing parts in order like this is now an error:

  • "lin_ap0_scene" "lin_ap1_scene"
  • "data" "lin_ap0_scene"
  • missing "lin_ap0_scene"

It also means "data" missing becomes "data" "data" on read.

I considered automatically reordering headers to accept cases where a "data" part happens to come first. However attributes in the first header have a special meaning, and reordering attributes other than colorInteropID to later headers would be problematic.

Ref AcademySoftwareFoundation/openexr#2560

Tests

New test added for this.

Checklist:

  • I have read the guidelines on contributions and code review procedures.
  • I have read the Policy on AI Coding Assistants
    and if I used AI coding assistants, I have an Assisted-by: TOOL / MODEL
    line in the pull request description above.
  • I have updated the documentation if my PR adds features or changes
    behavior.
  • I am sure that this PR's changes are tested in the testsuite.
  • I have run and passed the testsuite in CI before submitting the
    PR, by pushing the changes to my fork and seeing that the automated CI
    passed there. (Exceptions: If most tests pass and you can't figure out why
    the remaining ones fail, it's ok to submit the PR and ask for help. Or if
    any failures seem entirely unrelated to your change; sometimes things break
    on the GitHub runners.)
  • My code follows the prevailing code style of this project and I
    fixed any problems reported by the clang-format CI test.
  • If I added or modified a public C++ API call, I have also amended the
    corresponding Python bindings. If altering ImageBufAlgo functions, I also
    exposed the new functionality as oiiotool options.

On read, a part without a colorInteropID now gets it from the first part,
if there is any. There is no validation, EXR files that do not follow
the CIF recommendation are still accepted.

On write, give an error when the colorInteropID in later parts is
different than the first part, except if is missing or set to "data".
Upcoming versions of OpenEXR will throw an exception in this case, this
applies the same logic for existing versions of OpenEXR already.

Note this also means writing parts in order like this is now an error:
* "lin_ap0_scene", "lin_ap1_scene"
* "data", "lin_ap0_scene"
* missing, "lin_ap0_scene"

It also means "data" <missing> becomes "data" "data" on read.

I considered automatically reordering headers to accept cases where
a "data" part happens to come first. However attributes in the first
header have a special meaning, and reordering attributes other than
colorInteropID to later headers would be problematic.

Ref AcademySoftwareFoundation/openexr#2560

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
@brechtvl

Copy link
Copy Markdown
Contributor Author

CC @doug-walker @zachlewis

@brechtvl

brechtvl commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

This is more strict than I would have chosen myself, as I explained in the OpenEXR PR. But even if the rules were relaxed a bit, it still remains a breaking change that should probably be done sooner than later in 3.2.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

@doug-walker doug-walker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good Brecht, it seems to follow the CIF Recommendation.

You have raised a valid point that this will potentially refuse to write some files that would have been written before. Personally, I don't think that's undesirable since the parts would not be well-organized, but I'd be interested to hear from OIIO users if this is problematic for them.


// Follow the color interop forum recommendation for OpenEXR files,
// where the colorInteropID in later parts must match the first part,
// except when "data" or missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a note here, suggesting to replace this function with checkColorMetadata from the OpenEXR library, once that's available. It does some additional checks, such as validating acesImageContainer flag and chromaticities. (Though I realize that OIIO will need its own copy for a while due to the need to support older EXR versions.)

@brechtvl
brechtvl marked this pull request as draft August 26, 2026 10:54
@brechtvl

Copy link
Copy Markdown
Contributor Author

Converting to a draft for now since discussion in the OpenEXR PR is still ongoing, so best not to land this before a decision is made there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants