Skip to content

Commit 9585feb

Browse files
committed
allow thumbnail colourspace export with no import
allow this case: vipsthumbnail k2.jpg --export-profile cmyk for an image with no embedded profile
1 parent c4d56fd commit 9585feb

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

libvips/resample/thumbnail.c

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -855,23 +855,41 @@ vips_thumbnail_build( VipsObject *object )
855855
* to the output space.
856856
*/
857857
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+
}
870889
}
871890
else if( thumbnail->linear ) {
872891
/* 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.
875893
*/
876894
g_info( "reverting to input space %s",
877895
vips_enum_nick( VIPS_TYPE_INTERPRETATION,

0 commit comments

Comments
 (0)