AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO
[BUG] EXR files are always assumed to be "Linear" without checking a previously existing value for oiio:ColorSpace
- Dominant language
- C++
- Stars
- 2.4k
- Forks
- 698
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 48
Description
When reading an .exr file, the oiio:ColorSpace is always set to "Linear". If the read file already contained this metadata but set to another value (ACEScg for example), it is overwritten. I expected the original value to be retained.
The following piece of C++ code shows how to reproduce the bug:
```
const OIIO::ParamValue* p;
// Read input JPEG image
OIIO::ImageBuf imgBuf("path/to/my/file.jpg");
// Check oiio:ColorSpace value in the input image
p = imgBuf.spec().find_attribute("oiio:ColorSpace");
std::cout << "oiio:ColorSpace = " << ( p ? p->get_string() : "Undefined") << std::endl;
// Color Space conversion from sRGB to ACEScg
OIIO::ColorConfig colorConfig("path/to/my/config.ocio");
OIIO::ImageBuf colorspaceBuf;
OIIO::ImageBufAlgo::colorconvert(colorspaceBuf, imgBuf, "sRGB", "ACEScg", true, "", "", &colorConfig);
// Check oiio:ColorSpace value after conversion
p = colorspaceBuf.spec().find_attribute("oiio:ColorSpace");
std::cout << "oiio:ColorSpace = " << (p ? p->get_string() : "Undefined") << std::endl;
// Save converted image on disk as an .exr file
colorspaceBuf.write("path/to/my/convertedFile.exr");
// Read the stored .exr file
OIIO::ImageBuf imgBufNew("path/to/my/convertedFile.exr");
// Check oiio:ColorSpace value after reading the exr file
p = imgBufNew.spec().find_attribute("oiio:ColorSpace");
std::cout << "oiio:ColorSpace = " << (p ? p->get_string() : "Undefined") << std::endl;
```
This code produces the following output on the console:
```
oiio:ColorSpace = sRGB
oiio:ColorSpace = ACEScg
oiio:ColorSpace = Linear
```
I would expect that the last line to be:
`oiio:ColorSpace = ACEScg`
**Platform information:**
- OIIO picked and compiled through vcpkg package manager.
- OS: Windows 10
- C++ compiler: Visual Studio 2022 / platform x64
Contributor guide
Research direction
The report names OIIO::ImageBuf, ImageBufAlgo::colorconvert, and the EXR read/write path. Start by reproducing the metadata change with the supplied C++ example, then trace how EXR reading handles oiio:ColorSpace. Done means an existing value such as ACEScg is retained after writing and reading the EXR file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100