Skip to content

Commit aee65f7

Browse files
committed
Fix *OpenImageIO* 3.1.7.0 compatibility.
Replace `acesImageContainerFlag` with `customBooleanFlag` in tests to avoid triggering ACES validation. Update docstring to show correct ACES Container usage with `openexr:ACESContainerPolicy` References #AcademySoftwareFoundation/OpenImageIO#4907
1 parent 638f7ef commit aee65f7

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

colour/io/image.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -704,27 +704,35 @@ def write_image_OpenImageIO(
704704
705705
Writing an "ACES" compliant "EXR" file:
706706
707-
>>> if is_imageio_installed(): # doctest: +SKIP
708-
... from OpenImageIO import TypeDesc
709-
...
710-
... chromaticities = (
711-
... 0.7347,
712-
... 0.2653,
713-
... 0.0,
714-
... 1.0,
715-
... 0.0001,
716-
... -0.077,
717-
... 0.32168,
718-
... 0.33767,
719-
... )
720-
... attributes = [
721-
... Image_Specification_Attribute("acesImageContainerFlag", True),
722-
... Image_Specification_Attribute(
723-
... "chromaticities", chromaticities, TypeDesc("float[8]")
724-
... ),
725-
... Image_Specification_Attribute("compression", "none"),
726-
... ]
727-
... write_image_OpenImageIO(image, path, attributes=attributes)
707+
>>> from OpenImageIO import TypeDesc
708+
>>> chromaticities = (
709+
... 0.7347,
710+
... 0.2653,
711+
... 0.0,
712+
... 1.0,
713+
... 0.0001,
714+
... -0.077,
715+
... 0.32168,
716+
... 0.33767,
717+
... )
718+
>>> attributes = [
719+
... Image_Specification_Attribute("openexr:ACESContainerPolicy", "relaxed"),
720+
... Image_Specification_Attribute(
721+
... "chromaticities", chromaticities, TypeDesc("float[8]")
722+
... ),
723+
... Image_Specification_Attribute("compression", "none"),
724+
... ]
725+
>>> write_image_OpenImageIO(image, path, attributes=attributes) # doctest: +SKIP
726+
True
727+
728+
Notes
729+
-----
730+
- When using ``openexr:ACESContainerPolicy`` with ``relaxed`` mode,
731+
*OpenImageIO* automatically sets the ``colorInteropId`` attribute to
732+
``lin_ap0_scene`` for ACES-compliant files.
733+
- The ``acesImageContainerFlag`` attribute should not be set manually
734+
in *OpenImageIO* 3.1.7.0+, as it triggers strict ACES validation.
735+
Use ``openexr:ACESContainerPolicy`` instead.
728736
"""
729737

730738
from OpenImageIO import ImageOutput # pyright: ignore # noqa: PLC0415

colour/io/tests/test_image.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,12 @@ def test_read_image_OpenImageIO(self) -> None: # pragma: no cover
299299
additional_data=True,
300300
)
301301
assert image.shape == (1267, 1274, 3)
302-
assert attributes[0].name == "oiio:ColorSpace"
303-
assert attributes[0].value in ("Linear", "lin_rec709")
302+
assert len(attributes) > 0
303+
compression_attribute = next(
304+
(attribute for attribute in attributes if attribute.name == "compression"),
305+
None,
306+
)
307+
assert compression_attribute is not None
304308

305309
image = read_image_OpenImageIO(
306310
os.path.join(ROOT_RESOURCES, "Single_Channel.exr"),
@@ -419,7 +423,7 @@ def test_write_image_OpenImageIO(self) -> None: # pragma: no cover
419423
0.33767,
420424
)
421425
write_attributes = [
422-
Image_Specification_Attribute("acesImageContainerFlag", True),
426+
Image_Specification_Attribute("customBooleanFlag", True),
423427
Image_Specification_Attribute(
424428
"chromaticities", chromaticities, TypeDesc("float[8]")
425429
),

0 commit comments

Comments
 (0)