@@ -430,11 +430,11 @@ bool ImageConverter::parse_params( const OIIO::ArgParse &argParse )
430
430
431
431
headroom = argParse[" headroom" ].get <float >();
432
432
433
- std::string illum = argParse[" illuminant" ].get ();
433
+ illuminant = argParse[" illuminant" ].get ();
434
434
435
435
if ( wbMethod == WBMethod::Illuminant )
436
436
{
437
- if ( illum. size () == 0 )
437
+ if ( illuminant. empty () )
438
438
{
439
439
std::cerr << " Warning: the white balancing method was set to "
440
440
<< " \" illuminant\" , but no \" --illuminant\" parameter "
@@ -444,7 +444,7 @@ bool ImageConverter::parse_params( const OIIO::ArgParse &argParse )
444
444
}
445
445
else
446
446
{
447
- if ( illum. size () != 0 )
447
+ if ( !illuminant. empty () )
448
448
{
449
449
std::cerr << " Warning: the \" --illuminant\" parameter provided "
450
450
<< " but the white balancing mode different from "
@@ -529,13 +529,8 @@ bool ImageConverter::parse_params( const OIIO::ArgParse &argParse )
529
529
}
530
530
531
531
bool ImageConverter::configure (
532
- const std::string &input_filename , OIIO::ParamValueList &options )
532
+ const OIIO::ImageSpec &imageSpec , OIIO::ParamValueList &options )
533
533
{
534
- _read_raw = options.get_string ( " raw:Demosaic" ) == " none" ;
535
-
536
- OIIO::ImageSpec imageSpec;
537
-
538
- options[" raw:ColorSpace" ] = " XYZ" ;
539
534
options[" raw:use_camera_wb" ] = 0 ;
540
535
options[" raw:use_auto_wb" ] = 0 ;
541
536
@@ -553,16 +548,6 @@ bool ImageConverter::configure(
553
548
" raw:cropbox" , OIIO::TypeDesc ( OIIO::TypeDesc::INT, 4 ), cropbox );
554
549
}
555
550
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
-
566
551
_is_DNG = imageSpec.extra_attribs .find ( " raw:dng:version" )->get_int () > 0 ;
567
552
568
553
switch ( wbMethod )
@@ -635,7 +620,11 @@ bool ImageConverter::configure(
635
620
}
636
621
break ;
637
622
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 );
639
628
}
640
629
641
630
switch ( matrixMethod )
@@ -645,12 +634,16 @@ bool ImageConverter::configure(
645
634
options[" raw:use_camera_matrix" ] = 0 ;
646
635
break ;
647
636
case MatrixMethod::Metadata:
637
+ options[" raw:ColorSpace" ] = " XYZ" ;
648
638
options[" raw:use_camera_matrix" ] = _is_DNG ? 1 : 3 ;
649
639
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 ;
651
644
case MatrixMethod::Custom:
652
- options[" raw:use_camera_matrix" ] = 0 ;
653
645
options[" raw:ColorSpace" ] = " raw" ;
646
+ options[" raw:use_camera_matrix" ] = 0 ;
654
647
655
648
_IDT_matrix.resize ( 3 );
656
649
for ( int i = 0 ; i < 3 ; i++ )
@@ -661,9 +654,12 @@ bool ImageConverter::configure(
661
654
_IDT_matrix[i][j] = customMatrix[i][j];
662
655
}
663
656
}
664
-
665
657
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 );
667
663
}
668
664
669
665
bool spectral_white_balance = wbMethod == WBMethod::Illuminant;
@@ -711,6 +707,30 @@ bool ImageConverter::configure(
711
707
return true ;
712
708
}
713
709
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
+
714
734
bool ImageConverter::applyMatrix (
715
735
const std::vector<std::vector<double >> &matrix,
716
736
OIIO::ImageBuf &dst,
0 commit comments