Skip to content

Commit 3a2cf01

Browse files
lgritzdoug-walker
andcommitted
feat: color space renaming to adhere to CIF conventions (#4860)
This doesn't really change any of the color management algorithms per se, or change how we use OCIO. That will come later. But this tries as best as we can to shift to CIF recommended interop names for color spaces. * "srgb_rec709_scene" as the canonical name for what we used to refer to as "sRGB". * "lin_rec709_scene" as the canonical name for what we used to refer to as "lin_rec709" and several other names. * "lin_ap1_scene" as the canonical name for ACEScg. * Stop setting "oiio:Gamma" metadata (though we still accept it for back compatibility), instead using space names like "g22_rec709_scene" and so on. We never came across files with truly arbitrary gamma. If I've done it right, the old names will continue to be accepted as aliases. I recognize that changing the output (when printing metadata) to the canonical names might be an inconvenience at first, but in the long run, I think it's better to comply with the conventions that will be used for USD, MaterialX, and OpenEXR. I'm fine with the new wordy and pedantic names as what is stored underneath as the "oiio:ColorSpace" alias or stored in an OpenEXR file in the colorInteropID metadata. But I gotta say, from a UI/UX perspective, I do not feel good about replacing "srgb" and "acescg" as things that are easy to type and are known/understood by the vast majority of OIIO users with a change to these wonky, error-prone, hard-to-type names. So I'm very uncertain about changing oiiotool documentation, say, away from the short and widely understood aliases. Seeking feedback on what to do here! --------- Signed-off-by: Larry Gritz <[email protected]> Co-authored-by: Doug Walker <[email protected]>
1 parent 1f6203c commit 3a2cf01

File tree

80 files changed

+450
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+450
-405
lines changed

src/bmp.imageio/bmpinput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ BmpInput::open(const std::string& name, ImageSpec& newspec,
262262
// Default presumption is that a BMP file is meant to look reasonable on a
263263
// display, so assume it's sRGB. This is not really correct -- see the
264264
// comments below.
265-
m_spec.attribute("oiio:ColorSpace", "sRGB");
265+
m_spec.attribute("oiio:ColorSpace", "srgb_rec709_scene");
266266
#if 0
267267
if (m_dib_header.size >= WINDOWS_V4
268268
&& m_dib_header.cs_type == CSType::CalibratedRGB) {

src/build-scripts/build_opencolorio.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -ex
1111

1212
# Which OCIO to retrieve, how to build it
1313
OPENCOLORIO_REPO=${OPENCOLORIO_REPO:=https://github.com/AcademySoftwareFoundation/OpenColorIO.git}
14-
OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v2.3.2}
14+
OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v2.4.2}
1515

1616
# Where to install the final results
1717
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}

src/cmake/build_OpenColorIO.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# OpenColorIO by hand!
77
######################################################################
88

9-
set_cache (OpenColorIO_BUILD_VERSION 2.4.1 "OpenColorIO version for local builds")
9+
set_cache (OpenColorIO_BUILD_VERSION 2.4.2 "OpenColorIO version for local builds")
1010
set (OpenColorIO_GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/OpenColorIO")
1111
set (OpenColorIO_GIT_TAG "v${OpenColorIO_BUILD_VERSION}")
1212
set_cache (OpenColorIO_BUILD_SHARED_LIBS OFF #ON

src/dds.imageio/ddsinput.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,14 +838,16 @@ DDSInput::seek_subimage(int subimage, int miplevel)
838838
case DDS_FORMAT_BC7_UNORM_SRGB:
839839
case DDS_FORMAT_R8G8B8A8_UNORM_SRGB:
840840
case DDS_FORMAT_B8G8R8A8_UNORM_SRGB:
841-
case DDS_FORMAT_B8G8R8X8_UNORM_SRGB: colorspace = "sRGB"; break;
841+
case DDS_FORMAT_B8G8R8X8_UNORM_SRGB:
842+
colorspace = "srgb_rec709_scene";
843+
break;
842844
}
843845
}
844846

845847
// linear color space for HDR-ish images
846848
if (colorspace == nullptr
847849
&& (basetype == TypeDesc::HALF || basetype == TypeDesc::FLOAT))
848-
colorspace = "lin_rec709";
850+
colorspace = "lin_rec709_scene";
849851

850852
m_spec.set_colorspace(colorspace);
851853

src/doc/builtinplugins.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,6 @@ preferred except when legacy file access is required.
688688
- string
689689
- Color space (see Section :ref:`sec-metadata-color`). We currently
690690
assume that any RGBE files encountered are linear with sRGB primaries.
691-
* - ``oiio:Gamma``
692-
- float
693-
- the gamma correction specified in the RGBE header (if it's gamma corrected).
694691
* - ``heif:Orientation``
695692
- int
696693
- If the configuration option ``heif:reorient`` is nonzero and
@@ -1771,9 +1768,6 @@ files use the file extension :file:`.png`.
17711768
* - ``oiio:ColorSpace``
17721769
- string
17731770
- Color space (see Section :ref:`sec-metadata-color`).
1774-
* - ``oiio:Gamma``
1775-
- float
1776-
- the gamma correction value (if specified).
17771771
* - ``ICCProfile``
17781772
- uint8[]
17791773
- The ICC color profile. A variety of other ``ICCProfile:*`` attributes
@@ -2370,9 +2364,6 @@ software developed at Wavefront. RLA files commonly use the file extension
23702364
* - ``oiio:ColorSpace``
23712365
- string
23722366
- Color space (see Section :ref:`sec-metadata-color`).
2373-
* - ``oiio:Gamma``
2374-
- float
2375-
- the gamma correction value (if specified).
23762367

23772368
**Configuration settings for RLA input**
23782369

@@ -2611,9 +2602,6 @@ http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf
26112602
* - ``oiio:ColorSpace``
26122603
- string
26132604
- Color space (see Section :ref:`sec-metadata-color`).
2614-
* - ``oiio:Gamma``
2615-
- float
2616-
- the gamma correction value (if specified).
26172605

26182606
If the TGA file contains a thumbnail, its dimensions will be stored in the
26192607
attributes ``"thumbnail_width"``, ``"thumbnail_height"``, and

src/doc/oiiotool.rst

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,19 @@ Color convert an image
709709
----------------------
710710

711711
This command linearizes a JPEG assumed to be in sRGB, saving as an HDRI
712-
OpenEXR file::
712+
OpenEXR file in ACEScg color space::
713713

714-
oiiotool photo.jpg --colorconvert sRGB linear -o output.exr
714+
oiiotool photo.jpg --colorconvert srgb acescg -o output.exr
715715

716716
And the other direction::
717717

718-
oiiotool render.exr --colorconvert linear sRGB -o fortheweb.png
718+
oiiotool render.exr --colorconvert acescg srgb -o fortheweb.png
719+
720+
Above, we're using the short aliases "srgb" and "acescg", but it's also fine
721+
to use the canonical Color Interop Forum names::
722+
723+
oiiotool photo.jpg --colorconvert srgb_rec709_scene lin_ap1_scene -o output.exr
724+
oiiotool render.exr --colorconvert lin_ap1_scene srgb_rec709_scene -o fortheweb.png
719725

720726
This converts between two named color spaces (presumably defined by your
721727
facility's OpenColorIO configuration)::
@@ -1608,7 +1614,7 @@ Writing images
16081614

16091615
oiiotool in.tif -otex out.tx
16101616
1611-
oiiotool in.jpg --colorconvert sRGB linear -d uint16 -otex out.tx
1617+
oiiotool in.jpg --colorconvert srgb_rec709_scene lin_rec709_scene -d uint16 -otex out.tx
16121618
16131619
oiiotool --pattern:checker 512x512 3 -d uint8 -otex:wrap=periodic checker.tx
16141620
@@ -4352,15 +4358,12 @@ current top image.
43524358
Many of the color management commands depend on an installation of
43534359
OpenColorIO (http://opencolorio.org).
43544360

4355-
If OIIO has been compiled with OpenColorIO support and the environment
4356-
variable `$OCIO` is set to point to a valid OpenColorIO configuration file,
4357-
you will have access to all the color spaces that are known by that OCIO
4358-
configuration. Alternately, you can use the `--colorconfig` option to
4359-
explicitly point to a configuration file. If no valid configuration file is
4360-
found (either in `$OCIO` or specified by `--colorconfig}` or OIIO was not
4361-
compiled with OCIO support, then the only color space transformats available
4362-
are `linear` to `Rec709` (and vice versa) and `linear` to `sRGB` (and vice
4363-
versa).
4361+
If the environment variable `$OCIO` is set to point to a valid OpenColorIO
4362+
configuration file, you will have access to all the color spaces that are
4363+
known by that OCIO configuration. Alternately, you can use the
4364+
`--colorconfig` option to explicitly point to a configuration file. If no
4365+
valid configuration file is found (either in `$OCIO` or specified by
4366+
`--colorconfig`), then the built-in OCIO "default" config will be used.
43644367

43654368
If you ask for :program:`oiiotool` help (`oiiotool --help`), at the very
43664369
bottom you will see the list of all color spaces, looks, and displays that

src/doc/pythonbindings.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ Section :ref:`sec-ImageSpec`, is replicated for Python.
729729
.. code-block:: python
730730
731731
spec = ImageSpec(...)
732-
spec.set_colorspace ("sRGB")
732+
spec.set_colorspace ("srgb_rec709_scene")
733733
734734
735735
.. py:method:: ImageSpec.undefined ()
@@ -3961,12 +3961,12 @@ details.
39613961
.. code-block:: python
39623962
39633963
spec = oiio.ImageSpec()
3964-
oiio.set_colorspace (spec, "lin_rec709")
3964+
oiio.set_colorspace (spec, "lin_rec709_scene")
39653965
39663966
This function was added in OpenImageIO 3.0.
39673967
39683968
3969-
.. py:method:: set_colorspace_rec709_gamma (spec, name)
3969+
.. py:method:: set_colorspace_rec709_gamma (spec, gamma)
39703970
39713971
Set the metadata of the `spec` to reflect Rec709 color primaries and the
39723972
given gamma.
@@ -3992,7 +3992,7 @@ details.
39923992
39933993
# ib is an ImageBuf
39943994
cs = ib.spec().get_string_attribute("oiio:ColorSpace")
3995-
if oiio.equivalent_colorspace(cs, "sRGB") :
3995+
if oiio.equivalent_colorspace(cs, "srgb_rec709_scene") :
39963996
print ("The image is sRGB")
39973997
39983998
This function was added in OpenImageIO 3.0.

src/doc/stdmetadata.rst

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -139,34 +139,24 @@ Color information
139139

140140
.. option:: "oiio:ColorSpace" : string
141141

142-
The name of the color space of the color channels. Values include:
142+
The name of the color space of the color channels. This can be the name of
143+
any documented Color Interop Forum standard token, or any color space,
144+
alias, or role known to OpenColorIO. Common values include:
143145

144-
- `"scene_linear"` : Color pixel values are known to be scene-linear and
145-
using facility-default color primaries as defined by the OpenColorIO
146-
configuration.
147-
- `"lin_srgb"`, `"lin_rec709"` : Color pixel values are known to be
148-
linear and using sRGB/Rec709 color primaries. Note that `"linear"` is
149-
treated as a synonym.
150-
- `"sRGB"` : Using standard sRGB response and primaries.
151-
- `"Rec709"` : Using standard Rec709 response and primaries.
152-
- `"ACEScg"` : ACEScg color space encoding.
153-
- `"AdobeRGB"` : Adobe RGB color space.
154-
- `"KodakLog"` : Kodak logarithmic color space.
155-
- `"g22_rec709"` : Rec709/sRGB primaries, but using a response curve
146+
- `"lin_rec709_scene"`, : Color pixel values are known to be linear
147+
scene-referred and using sRGB/Rec709 color primaries. Note that
148+
`"lin_rec709"` is treated as a synonym.
149+
- `"lin_ap1_scene"`, `"ACEScg"` : ACEScg color space encoding.
150+
- `"lin_ap0_scene"` : ACES2065-1, the recommended ACES space for
151+
interchange and archiving.
152+
- `"srgb_rec709_scene"` : Using standard (piecewise) sRGB response and
153+
primaries. The token `"sRGB"` is treated as a synonym.
154+
- `"g22_rec709_scene"` : Rec709/sRGB primaries, but using a response curve
156155
corresponding to gamma 2.2.
157-
- `"g18_rec709"` : Rec709/sRGB primaries, but using a response curve
158-
corresponding to gamma 1.8.
159-
- `"GammaX.Y"` : Color values have been gamma corrected
160-
(raised to the power :math:`1/\gamma`). The `X.Y` is the numeric value
161-
of the gamma exponent.
162-
- *arbitrary* : The name of any color space known to OpenColorIO (if
163-
OCIO support is present).
164-
165-
.. option:: "oiio:Gamma" : float
166-
167-
If the color space is "GammaX.Y", this value is the gamma exponent.
168-
(Optional/deprecated; if present, it should match the suffix of the color
169-
space.)
156+
157+
Additionally, `"scene_linear"` is a role that is appropriate for color
158+
pixel values are known to be scene-linear and using facility-default color
159+
primaries as defined by the OpenColorIO configuration.
170160

171161
.. option:: "oiio:BorderColor" : float[nchannels]
172162

src/gif.imageio/gifinput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ GIFInput::read_subimage_metadata(ImageSpec& newspec)
259259
newspec.nchannels = 4;
260260
newspec.default_channel_names();
261261
newspec.alpha_channel = 4;
262-
newspec.set_colorspace("sRGB");
262+
newspec.set_colorspace("srgb_rec709_scene");
263263

264264
m_previous_disposal_method = m_disposal_method;
265265
m_disposal_method = DISPOSAL_UNSPECIFIED;

src/hdr.imageio/hdrinput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ HdrInput::RGBE_ReadHeader()
291291
if (!line.size())
292292
return false;
293293

294-
m_spec.set_colorspace("lin_rec709");
294+
m_spec.set_colorspace("lin_rec709_scene");
295295
// presume linear w/ srgb primaries -- seems like the safest assumption
296296
// for this old file format.
297297

0 commit comments

Comments
 (0)