Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ A help message with a description of all command line options can be obtained by
--version Print version and exit
--wb-method STR White balance method. Supported options: metadata, illuminant, box, custom. (default: metadata)
--mat-method STR IDT matrix calculation method. Supported options: auto, spectral, metadata, Adobe, custom. (default: auto)
--illuminant STR Illuminant for white balancing. (default = D55)
--wb-box X Y W H Box to use for white balancing. (default = (0,0,0,0) - full image)
--illuminant STR Illuminant for white balancing. (default: D55)
--wb-box X Y W H Box to use for white balancing. (default: (0,0,0,0) - full image)
--custom-wb R G B G Custom white balance multipliers.
--custom-mat Rr Rg Rb Gr Gg Gb Br Bg Bb
Custom camera RGB to XYZ matrix.
Expand All @@ -219,6 +219,7 @@ A help message with a description of all command line options can be obtained by
--data-dir STR Directory containing rawtoaces spectral sensitivity and illuminant data files. Overrides the default search path and the RAWTOACES_DATA_PATH environment variable.
--output-dir STR The directory to write the output files to. This gets applied to every input directory, so it is better to be used with a single input directory.
--create-dirs Create output directories if they don't exist.
--compression STR Output file compression type. Supported options: none, rle, zip, zips, piz, pxr24, b44, b44a, dwaa, dwab, htj2k256, htj2k32. (default: none)
--disable-cache Disable the colour space transform cache.
Raw conversion options:
--auto-bright Enable automatic exposure adjustment.
Expand Down
3 changes: 3 additions & 0 deletions include/rawtoaces/image_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ class ImageConverter
/// The directory to write the output files to.
std::string output_dir;

/// Output file compression type.
std::string compression;

//----------------------------------------------------------------------
// Lens correction:

Expand Down
1 change: 1 addition & 0 deletions src/bindings/py_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void util_bindings( nanobind::module_ &m )
settings.def_rw( "overwrite", &ImageConverter::Settings::overwrite );
settings.def_rw( "create_dirs", &ImageConverter::Settings::create_dirs );
settings.def_rw( "output_dir", &ImageConverter::Settings::output_dir );
settings.def_rw( "compression", &ImageConverter::Settings::compression );
settings.def_rw( "use_timing", &ImageConverter::Settings::use_timing );
settings.def_rw( "verbosity", &ImageConverter::Settings::verbosity );

Expand Down
32 changes: 28 additions & 4 deletions src/rawtoaces_util/image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,13 +802,13 @@ void ImageConverter::init_parser( OIIO::ArgParse &arg_parser )
.action( OIIO::ArgParse::store() );

arg_parser.arg( "--illuminant" )
.help( "Illuminant for white balancing. (default = D55)" )
.help( "Illuminant for white balancing. (default: D55)" )
.metavar( "STR" )
.action( OIIO::ArgParse::store() );

arg_parser.arg( "--wb-box" )
.help(
"Box to use for white balancing. (default = (0,0,0,0) - full "
"Box to use for white balancing. (default: (0,0,0,0) - full "
"image)" )
.nargs( 4 )
.metavar( "X Y W H" )
Expand Down Expand Up @@ -940,6 +940,14 @@ void ImageConverter::init_parser( OIIO::ArgParse &arg_parser )
.help( "Create output directories if they don't exist." )
.action( OIIO::ArgParse::store_true() );

arg_parser.arg( "--compression" )
.help(
"Output file compression type. Supported options: none, rle, "
"zip, zips, piz, pxr24, b44, b44a, dwaa, dwab, htj2k256, htj2k32. "
"(default: none)" )
.metavar( "STR" )
.action( OIIO::ArgParse::store() );

arg_parser.separator( "Raw conversion options:" );

arg_parser.arg( "--auto-bright" )
Expand Down Expand Up @@ -1350,6 +1358,8 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser )
settings.scale = arg_parser["scale"].get<float>();
settings.denoise_threshold = arg_parser["denoise-threshold"].get<float>();

settings.compression = arg_parser["compression"].get();

settings.overwrite = arg_parser["overwrite"].get<int>();
settings.create_dirs = arg_parser["create-dirs"].get<int>();
settings.output_dir = arg_parser["output-dir"].get();
Expand Down Expand Up @@ -2600,14 +2610,28 @@ bool ImageConverter::save_image(

OIIO::ImageSpec image_spec = buf.spec();
image_spec.set_format( OIIO::TypeDesc::HALF );
image_spec["acesImageContainerFlag"] = 1;
image_spec["compression"] = "none";
image_spec.attribute(
"chromaticities",
OIIO::TypeDesc( OIIO::TypeDesc::FLOAT, 8 ),
chromaticities );
image_spec["oiio:ColorSpace"] = "lin_ap0_scene";

const auto &compression = settings.compression;
if ( compression.empty() || compression == "none" )
{
image_spec["acesImageContainerFlag"] = 1;
image_spec["compression"] = "none";
}
else
{
image_spec["acesImageContainerFlag"] = 0;
image_spec["compression"] = compression;

std::cerr << "Warning: The ST2065-4 standard does not allow compressed "
<< "files. The output file is not AcesContainer-compliant."
<< std::endl;
}

auto image_output = OIIO::ImageOutput::create( "exr" );
bool result = image_output->open( output_filename, image_spec );
if ( result )
Expand Down
5 changes: 4 additions & 1 deletion tests/python/test_image_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ def test_settings_attributes(self):

converter.settings.output_dir = "output_dir"
assert converter.settings.output_dir == "output_dir"


converter.settings.compression = "zip"
assert converter.settings.compression == "zip"

converter.settings.use_timing = True
assert converter.settings.use_timing == True

Expand Down
27 changes: 27 additions & 0 deletions tests/test_image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2934,6 +2934,30 @@ void test_custom_wb_being_set()
OIIO_CHECK_EQUAL_THRESH( wb_multipliers[3], 1.2f, 1e-5 );
}

void test_compression_warning()
{
std::cout << std::endl << __FUNCTION__ << std::endl;

if ( OIIO::openimageio_version() < 30000 )
return;

ImageConverter converter;
converter.settings.overwrite = true;
converter.settings.compression = "zip";

std::string test_file = std::filesystem::absolute( dng_test_file ).string();

bool result;
auto output = capture_stderr(
[&]() { result = converter.process_image( test_file ); } );

OIIO_CHECK_ASSERT( result );
ASSERT_CONTAINS(
output,
"Warning: The ST2065-4 standard does not allow "
"compressed files" );
}

int main( int, char ** )
{
try
Expand Down Expand Up @@ -3053,6 +3077,9 @@ int main( int, char ** )

// Tests for lens correction types
test_lens_correction_type();

// Test compression warning.
test_compression_warning();
}
catch ( const std::exception &e )
{
Expand Down
Loading