Skip to content

Commit

Permalink
Try to get oiio:ColorSpace metadata from read buffer before using the…
Browse files Browse the repository at this point in the history
… readmetadata oiio function based on filepath.
  • Loading branch information
demoulinv committed Oct 8, 2022
1 parent a0c1a52 commit c8a0c19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/aliceVision/image/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ EImageColorSpace EImageColorSpace_stringToEnum(const std::string& dataType)
return EImageColorSpace::LINEAR;
if(type == "srgb")
return EImageColorSpace::SRGB;
if(type == "ACES2065-1")
if(type == "aces2065-1")
return EImageColorSpace::ACES2065_1;
if(type == "acescg")
return EImageColorSpace::ACEScg;
Expand All @@ -169,7 +169,7 @@ std::string EImageColorSpace_enumToString(const EImageColorSpace dataType)
case EImageColorSpace::SRGB:
return "srgb";
case EImageColorSpace::ACES2065_1:
return "ACES2065-1";
return "aces2065-1";
case EImageColorSpace::ACEScg:
return "acescg";
case EImageColorSpace::NO_CONVERSION:
Expand Down Expand Up @@ -508,8 +508,12 @@ void readImage(const std::string& path,

if (imageReadOptions.workingColorSpace != EImageColorSpace::NO_CONVERSION)
{
std::string inputColorSpace;
inputColorSpace = EImageColorSpace_enumToString(getImageColorSpace(path));
std::string inputColorSpace = inBuf.spec().get_string_attribute("oiio:ColorSpace", "");
if (inputColorSpace.empty())
{
// Try to get color space using filename
inputColorSpace = EImageColorSpace_enumToString(getImageColorSpace(path));
}
if (EImageColorSpace_stringToEnum(boost::to_lower_copy(inputColorSpace)) != imageReadOptions.workingColorSpace)
{
std::string outputColorSpace = (imageReadOptions.workingColorSpace == EImageColorSpace::LINEAR) ? "linear" : EImageColorSpace_enumToString(imageReadOptions.workingColorSpace);
Expand Down
2 changes: 0 additions & 2 deletions src/aliceVision/image/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ std::istream& operator>>(std::istream& in, EImageColorSpace& dataType);

void initColorConfigOCIO(const std::string& colorConfigFilePath);

EImageColorSpace getImageColorSpace(const std::string imagePath);

/**
* @brief Available image file type for pipeline output
*/
Expand Down

0 comments on commit c8a0c19

Please sign in to comment.