@@ -855,23 +855,41 @@ vips_thumbnail_build( VipsObject *object )
855
855
* to the output space.
856
856
*/
857
857
g_info ( "transforming to %s" , thumbnail -> export_profile );
858
- if ( thumbnail -> import_profile )
859
- g_info ( "fallback input profile %s" ,
860
- thumbnail -> import_profile );
861
-
862
- if ( vips_icc_transform ( in , & t [7 ],
863
- thumbnail -> export_profile ,
864
- "input_profile" , thumbnail -> import_profile ,
865
- "intent" , thumbnail -> intent ,
866
- "embedded" , TRUE,
867
- NULL ) )
868
- return ( -1 );
869
- in = t [7 ];
858
+
859
+ /* If there's some kind of import profile, we can transform to
860
+ * the output. Otherwise we have to convert to PCS and then
861
+ * export.
862
+ */
863
+ if ( thumbnail -> import_profile ||
864
+ (vips_image_get_typeof ( in , VIPS_META_ICC_NAME ) ||
865
+ thumbnail -> import_profile ) ) {
866
+ g_info ( "transforming with supplied profiles" );
867
+ if ( vips_icc_transform ( in , & t [7 ],
868
+ thumbnail -> export_profile ,
869
+ "input_profile" , thumbnail -> import_profile ,
870
+ "intent" , thumbnail -> intent ,
871
+ "embedded" , TRUE,
872
+ NULL ) )
873
+ return ( -1 );
874
+
875
+ in = t [7 ];
876
+ }
877
+ else {
878
+ g_info ( "exporting with %s" ,
879
+ thumbnail -> export_profile );
880
+ if ( vips_colourspace ( in , & t [7 ],
881
+ VIPS_INTERPRETATION_XYZ , NULL ) ||
882
+ vips_icc_export ( t [7 ], & t [8 ],
883
+ "output_profile" , thumbnail -> export_profile ,
884
+ "intent" , thumbnail -> intent ,
885
+ NULL ) )
886
+ return ( -1 );
887
+ in = t [8 ];
888
+ }
870
889
}
871
890
else if ( thumbnail -> linear ) {
872
891
/* Linear mode, no colour management. We went to scRGB for
873
- * processing, so we now revert to the input
874
- * colourspace.
892
+ * processing, so we now revert to the input colourspace.
875
893
*/
876
894
g_info ( "reverting to input space %s" ,
877
895
vips_enum_nick ( VIPS_TYPE_INTERPRETATION ,
0 commit comments