@@ -430,11 +430,11 @@ bool ImageConverter::parse_params( const OIIO::ArgParse &argParse )
430430
431431 headroom = argParse[" headroom" ].get <float >();
432432
433- std::string illum = argParse[" illuminant" ].get ();
433+ illuminant = argParse[" illuminant" ].get ();
434434
435435 if ( wbMethod == WBMethod::Illuminant )
436436 {
437- if ( illum. size () == 0 )
437+ if ( illuminant. empty () )
438438 {
439439 std::cerr << " Warning: the white balancing method was set to "
440440 << " \" illuminant\" , but no \" --illuminant\" parameter "
@@ -444,7 +444,7 @@ bool ImageConverter::parse_params( const OIIO::ArgParse &argParse )
444444 }
445445 else
446446 {
447- if ( illum. size () != 0 )
447+ if ( !illuminant. empty () )
448448 {
449449 std::cerr << " Warning: the \" --illuminant\" parameter provided "
450450 << " but the white balancing mode different from "
@@ -529,13 +529,8 @@ bool ImageConverter::parse_params( const OIIO::ArgParse &argParse )
529529}
530530
531531bool ImageConverter::configure (
532- const std::string &input_filename , OIIO::ParamValueList &options )
532+ const OIIO::ImageSpec &imageSpec , OIIO::ParamValueList &options )
533533{
534- _read_raw = options.get_string ( " raw:Demosaic" ) == " none" ;
535-
536- OIIO::ImageSpec imageSpec;
537-
538- options[" raw:ColorSpace" ] = " XYZ" ;
539534 options[" raw:use_camera_wb" ] = 0 ;
540535 options[" raw:use_auto_wb" ] = 0 ;
541536
@@ -553,16 +548,6 @@ bool ImageConverter::configure(
553548 " raw:cropbox" , OIIO::TypeDesc ( OIIO::TypeDesc::INT, 4 ), cropbox );
554549 }
555550
556- OIIO::ImageSpec temp_spec;
557- temp_spec.extra_attribs = options;
558-
559- auto imageInput = OIIO::ImageInput::create ( " raw" , false , &temp_spec );
560- bool result = imageInput->open ( input_filename, imageSpec, temp_spec );
561- if ( !result )
562- {
563- return false ;
564- }
565-
566551 _is_DNG = imageSpec.extra_attribs .find ( " raw:dng:version" )->get_int () > 0 ;
567552
568553 switch ( wbMethod )
@@ -635,7 +620,11 @@ bool ImageConverter::configure(
635620 }
636621 break ;
637622
638- default : break ;
623+ default :
624+ std::cerr
625+ << " ERROR: This white balancing method has not been configured "
626+ << " properly." << std::endl;
627+ exit ( 1 );
639628 }
640629
641630 switch ( matrixMethod )
@@ -645,12 +634,16 @@ bool ImageConverter::configure(
645634 options[" raw:use_camera_matrix" ] = 0 ;
646635 break ;
647636 case MatrixMethod::Metadata:
637+ options[" raw:ColorSpace" ] = " XYZ" ;
648638 options[" raw:use_camera_matrix" ] = _is_DNG ? 1 : 3 ;
649639 break ;
650- case MatrixMethod::Adobe: options[" raw:use_camera_matrix" ] = 1 ; break ;
640+ case MatrixMethod::Adobe:
641+ options[" raw:ColorSpace" ] = " XYZ" ;
642+ options[" raw:use_camera_matrix" ] = 1 ;
643+ break ;
651644 case MatrixMethod::Custom:
652- options[" raw:use_camera_matrix" ] = 0 ;
653645 options[" raw:ColorSpace" ] = " raw" ;
646+ options[" raw:use_camera_matrix" ] = 0 ;
654647
655648 _IDT_matrix.resize ( 3 );
656649 for ( int i = 0 ; i < 3 ; i++ )
@@ -661,9 +654,12 @@ bool ImageConverter::configure(
661654 _IDT_matrix[i][j] = customMatrix[i][j];
662655 }
663656 }
664-
665657 break ;
666- default : break ;
658+ default :
659+ std::cerr
660+ << " ERROR: This matrix method has not been configured properly."
661+ << std::endl;
662+ exit ( 1 );
667663 }
668664
669665 bool spectral_white_balance = wbMethod == WBMethod::Illuminant;
@@ -711,6 +707,30 @@ bool ImageConverter::configure(
711707 return true ;
712708}
713709
710+ bool ImageConverter::configure (
711+ const std::string &input_filename, OIIO::ParamValueList &options )
712+ {
713+ _read_raw = options.get_string ( " raw:Demosaic" ) == " none" ;
714+
715+ OIIO::ImageSpec imageSpec;
716+
717+ options[" raw:ColorSpace" ] = " XYZ" ;
718+ options[" raw:use_camera_wb" ] = 0 ;
719+ options[" raw:use_auto_wb" ] = 0 ;
720+
721+ OIIO::ImageSpec temp_spec;
722+ temp_spec.extra_attribs = options;
723+
724+ auto imageInput = OIIO::ImageInput::create ( " raw" , false , &temp_spec );
725+ bool result = imageInput->open ( input_filename, imageSpec, temp_spec );
726+ if ( !result )
727+ {
728+ return false ;
729+ }
730+
731+ return configure ( imageSpec, options );
732+ }
733+
714734bool ImageConverter::applyMatrix (
715735 const std::vector<std::vector<double >> &matrix,
716736 OIIO::ImageBuf &dst,
0 commit comments