@@ -649,11 +649,6 @@ vips_thumbnail_build( VipsObject *object )
649
649
*/
650
650
gboolean have_imported ;
651
651
652
- /* If we shrink in linear space, we need to return to the input
653
- * colourspace after the shrink.
654
- */
655
- VipsInterpretation input_interpretation ;
656
-
657
652
/* The format we need to revert to after unpremultiply.
658
653
*/
659
654
VipsBandFormat unpremultiplied_format ;
@@ -701,10 +696,6 @@ vips_thumbnail_build( VipsObject *object )
701
696
in = t [12 ];
702
697
}
703
698
704
- /* Note the interpretation we will revert to after linear.
705
- */
706
- input_interpretation = in -> Type ;
707
-
708
699
/* In linear mode, we need to transform to a linear space before
709
700
* vips_resize().
710
701
*/
@@ -792,7 +783,7 @@ vips_thumbnail_build( VipsObject *object )
792
783
793
784
/* vips_premultiply() makes a float image, so when we unpremultiply
794
785
* below we must cast back to the original format. Use NOTSET to
795
- * meran no pre/unmultiply.
786
+ * mean no pre/unmultiply.
796
787
*/
797
788
unpremultiplied_format = VIPS_FORMAT_NOTSET ;
798
789
@@ -841,75 +832,51 @@ vips_thumbnail_build( VipsObject *object )
841
832
842
833
/* Colour management.
843
834
*/
844
- if ( have_imported ) {
845
- /* We've already imported, just export. Go to sRGB if there's
846
- * no export profile.
835
+ if ( have_imported ) {
836
+ /* We are in PCS. Export with the output profile, if any (this
837
+ * will export with the embedded input profile if there's no
838
+ * export profile).
847
839
*/
848
- if ( thumbnail -> export_profile ||
849
- vips_image_get_typeof ( in , VIPS_META_ICC_NAME ) ) {
850
- g_info ( "exporting to device space with a profile" );
851
- if ( vips_icc_export ( in , & t [7 ],
852
- "output_profile" , thumbnail -> export_profile ,
853
- "intent" , thumbnail -> intent ,
854
- NULL ) )
855
- return ( -1 );
856
- in = t [7 ];
857
- }
858
- else {
859
- g_info ( "converting to sRGB" );
860
- if ( vips_colourspace ( in , & t [7 ],
861
- VIPS_INTERPRETATION_sRGB , NULL ) )
862
- return ( -1 );
863
- in = t [7 ];
864
- }
840
+ g_info ( "exporting to device space with a profile" );
841
+ if ( vips_icc_export ( in , & t [7 ],
842
+ "output_profile" , thumbnail -> export_profile ,
843
+ "intent" , thumbnail -> intent ,
844
+ NULL ) )
845
+ return ( -1 );
846
+ in = t [7 ];
865
847
}
866
848
else if ( thumbnail -> export_profile ) {
867
- /* Not imported, but we are doing colour management. Transform
868
- * to the output space.
869
- */
870
- g_info ( "transforming to %s" , thumbnail -> export_profile );
871
-
872
- /* If there's some kind of import profile, we can transform to
873
- * the output. Otherwise we have to convert to PCS and then
874
- * export.
849
+ /* We are in one of the resize space (sRGB, scRGB, B_W, GREY16,
850
+ * etc.) and we have an export profile. Go to PCS, then export.
875
851
*/
876
- if ( thumbnail -> import_profile ||
877
- ( vips_image_get_typeof ( in , VIPS_META_ICC_NAME ) ||
878
- thumbnail -> import_profile ) ) {
879
- g_info ( "transforming with supplied profiles" );
880
- if ( vips_icc_transform ( in , & t [7 ],
881
- thumbnail -> export_profile ,
882
- "input_profile" , thumbnail -> import_profile ,
852
+ g_info ( "exporting with %s" ,
853
+ thumbnail -> export_profile );
854
+ if ( vips_colourspace ( in , & t [ 7 ],
855
+ VIPS_INTERPRETATION_XYZ , NULL ) ||
856
+ vips_icc_export ( t [ 7 ] , & t [10 ],
857
+ "output_profile" ,
858
+ thumbnail -> export_profile ,
883
859
"intent" , thumbnail -> intent ,
884
- "embedded" , TRUE,
885
- NULL ) )
886
- return ( -1 );
887
-
888
- in = t [7 ];
889
- }
890
- else {
891
- g_info ( "exporting with %s" ,
892
- thumbnail -> export_profile );
893
- if ( vips_colourspace ( in , & t [7 ],
894
- VIPS_INTERPRETATION_XYZ , NULL ) ||
895
- vips_icc_export ( t [7 ], & t [10 ],
896
- "output_profile" ,
897
- thumbnail -> export_profile ,
898
- "intent" , thumbnail -> intent ,
899
- NULL ) )
900
- return ( -1 );
901
- in = t [10 ];
902
- }
860
+ NULL ) )
861
+ return ( -1 );
862
+ in = t [10 ];
903
863
}
904
- else if ( thumbnail -> linear ) {
905
- /* Linear mode, no colour management. We went to scRGB for
906
- * processing, so we now revert to the input colourspace.
864
+ else {
865
+ /* We are in one of the resize spaces and there's no export
866
+ * profile. Output to sRGB or B_W
907
867
*/
908
- g_info ( "reverting to input space %s" ,
868
+ VipsInterpretation interpretation ;
869
+
870
+ if ( in -> Bands < 3 )
871
+ interpretation = VIPS_INTERPRETATION_B_W ;
872
+ else
873
+ interpretation = VIPS_INTERPRETATION_sRGB ;
874
+
875
+ g_info ( "converting to output space %s" ,
909
876
vips_enum_nick ( VIPS_TYPE_INTERPRETATION ,
910
- input_interpretation ) );
911
- if ( vips_colourspace ( in , & t [7 ],
912
- input_interpretation , NULL ) )
877
+ interpretation ) );
878
+ if ( vips_colourspace ( in , & t [7 ], interpretation ,
879
+ NULL ) )
913
880
return ( -1 );
914
881
in = t [7 ];
915
882
}
0 commit comments