Skip to content

api(ColorConfig): add isData, fix python isColorSpaceLinear.#5191

Merged
lgritz merged 2 commits into
AcademySoftwareFoundation:mainfrom
lgritz:lg-isdata
May 13, 2026
Merged

api(ColorConfig): add isData, fix python isColorSpaceLinear.#5191
lgritz merged 2 commits into
AcademySoftwareFoundation:mainfrom
lgritz:lg-isdata

Conversation

@lgritz
Copy link
Copy Markdown
Collaborator

@lgritz lgritz commented May 10, 2026

  • Add ColorConfig::isData(name) method to C++ and Python APIs.
  • Fix ColorConfig.isColorSpaceLinear() that was missing from the Python bindings. (Tests added as well.)

* Add `ColorConfig::isData(name)` method to C++ and Python APIs.
* Fix `ColorConfig.isColorSpaceLinear()` that was missing from the
  Python bindings. (Tests added as well.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz lgritz requested a review from zachlewis May 10, 2026 07:10
@lgritz
Copy link
Copy Markdown
Collaborator Author

lgritz commented May 12, 2026

@zachlewis Does this look good to you?

Copy link
Copy Markdown
Collaborator

@zachlewis zachlewis left a comment

Choose a reason for hiding this comment

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

I think this is the right direction for sure; would prefer you check the "data" role instead of assuming "Raw" always points to a data space. Other than that, LGTM!

Comment thread src/libOpenImageIO/color_ocio.cpp Outdated
ACEScg_alias);
} else if (Strutil::iequals(cs.name, "Rec709")) {
cs.setflag(CSInfo::is_Rec709, Rec709_alias);
} else if (Strutil::iequals(cs.name, "Raw")) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not in favor of these string-based assumptions. Aren't we catching these cases with OCIO's API in a subsequent classification stage anyway?

In any case, if you do want to have a fast path to selecting color spaces we know are data spaces, without having to actually inspect them, you can try looking up the "data" role, which is MUCH more likely to point to a data color space than assuming the current config has a color space named "Raw", and that "Raw" is a data color space.

You can try Config::getCanonicalColorSpaceName("data"), which will either return the name of a color space that can be mapped to the "data" colorInteropID (or any other data color space needs); or it will return something falsey if the "data" role isn't set (I think it usually is -- IIRC, configs fail to validate otherwise).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I see your point here, and amended the PR with a change that uses getCanonicalColorSpaceName rather than hard-coding the name.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz lgritz merged commit 90f308b into AcademySoftwareFoundation:main May 13, 2026
62 checks passed
@lgritz lgritz deleted the lg-isdata branch May 13, 2026 04:43
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