Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/inst
```

```sh
$ brew install cmake ceres-solver imath boost
$ brew install ceres-solver nlohmann-json openimageio nanobind robin-map
```

```sh
$ python3 -m pip install --break-system-packages pytest
```

### Linux
Expand Down
8 changes: 8 additions & 0 deletions src/rawtoaces_util/image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,13 +1825,21 @@ bool ImageConverter::save_image(
"chromaticities",
OIIO::TypeDesc( OIIO::TypeDesc::FLOAT, 8 ),
chromaticities );
image_spec["oiio:ColorSpace"] = "lin_ap0_scene";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

core fix


auto image_output = OIIO::ImageOutput::create( "exr" );
bool result = image_output->open( output_filename, image_spec );
if ( result )
{
result = buf.write( image_output.get() );
}
else
{
std::cerr << "ERROR: Failed to open the file: " << output_filename
<< std::endl
<< "Error: " << image_output->geterror() << std::endl;
}

return result;
}

Expand Down
25 changes: 23 additions & 2 deletions tests/usage_example_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@
// This file contains some usage examples of the util library.
// It has only very little unit test functionality to keep the code clean.

namespace
{
std::string create_temp_output_dir()
{
static const std::string dir_name = "rawtoaces_usage_example_output";
std::filesystem::path temp_output_dir =
std::filesystem::temp_directory_path() / dir_name;
std::cout << "Output dir: " << temp_output_dir << std::endl;
std::filesystem::create_directories( temp_output_dir );
return temp_output_dir.string();
}
} // namespace

/// Test the image converter using command line parameters for intialisation.
void test_ImageConverter_arguments()
{
std::cout << "Running test_ImageConverter_arguments" << std::endl;
// This test fails on CI runners having an old version of OIIO.
if ( OIIO::openimageio_version() < 30000 )
return;
Expand All @@ -23,8 +37,12 @@ void test_ImageConverter_arguments()
std::filesystem::absolute( image_path ).string();

// Input parameters.
const char *argv[] = { "DUMMY PROGRAM PATH", "--wb-method", "metadata",
"--mat-method", "metadata", "--overwrite" };
std::string temp_output_dir = create_temp_output_dir();
const char *argv[] = { "DUMMY PROGRAM PATH", "--wb-method",
"metadata", "--mat-method",
"metadata", "--overwrite",
"--output-dir", temp_output_dir.c_str(),
"--verbose" };

const size_t argc = sizeof( argv ) / sizeof( argv[0] );

Expand All @@ -45,6 +63,7 @@ void test_ImageConverter_arguments()
/// Test the image converter, initialising the settings struct directly.
void test_ImageConverter_settings()
{
std::cout << "Running test_ImageConverter_settings" << std::endl;
// This test fails on CI runners having an old version of OIIO.
if ( OIIO::openimageio_version() < 30000 )
return;
Expand All @@ -56,11 +75,13 @@ void test_ImageConverter_settings()

// Configure the converter.
rta::util::ImageConverter converter;
converter.settings.output_dir = create_temp_output_dir();
converter.settings.WB_method =
rta::util::ImageConverter::Settings::WBMethod::Metadata;
converter.settings.matrix_method =
rta::util::ImageConverter::Settings::MatrixMethod::Metadata;
converter.settings.overwrite = true;
converter.settings.verbosity = 1;

// Process an image.
bool result = converter.process_image( absolute_image_path );
Expand Down