Skip to content

Commit

Permalink
add the cropbox parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
  • Loading branch information
antond-weta committed Sep 1, 2024
1 parent c167119 commit 279b5f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/rawtoaces/rawtoaces_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class ImageConverter
bool half_size = false;
int highlight_mode = 0;
int flip = 0;
int cropbox[4] = { 0, 0, 0, 0 };

int verbosity;

Expand Down
21 changes: 21 additions & 0 deletions src/rawtoaces_util2/rawtoaces_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ void ImageConverter::initArgParse()
.defaultval( 0 )
.action( OIIO::ArgParse::store<int>() );

_argParse.arg( "--cropbox" )
.help(
"Apply custom crop. If not present, the default crop is applied, "
"which should match the crop of the in-camera JPEG." )
.nargs( 4 )
.metavar( "X Y W H" )
.action( OIIO::ArgParse::store<int>() );

_argParse.arg( "--flip" )
.help(
"If not 0, override the orientation specified in the metadata. "
Expand Down Expand Up @@ -521,6 +529,13 @@ bool ImageConverter::parse( int argc, const char *argv[] )
customMatrix[i][j] = i == j ? 1.0 : 0.0;
} );

auto crop = _argParse["cropbox"].as_vec<int>();
if ( crop.size() == 4 )
{
for ( size_t i = 0; i < 4; i++ )
cropbox[i] = crop[i];
}

no_auto_bright = _argParse["no-auto-bright"].get<int>();
adjust_maximum_threshold = _argParse["adjust-maximum-threshold"].get<int>();
black_level = _argParse["black-level"].get<int>();
Expand Down Expand Up @@ -550,6 +565,12 @@ bool ImageConverter::configure( const std::string &input_filename )
_inputHint["raw:flip"] = flip;
_inputHint["raw:HighlightMode"] = highlight_mode;

if ( cropbox[2] != 0 && cropbox[3] != 0 )
{
_inputHint.attribute(
"raw:cropbox", OIIO::TypeDesc( OIIO::TypeDesc::INT, 4 ), cropbox );
}

auto imageInput = OIIO::ImageInput::create( "raw", false, &_inputHint );
imageInput->open( input_filename, _inputFull, _inputHint );

Expand Down

0 comments on commit 279b5f0

Please sign in to comment.