From da7b62680d1465d366671263e76f742dc797d1b1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 1 Jan 2018 18:52:54 +0000 Subject: [PATCH] simpler profile handling for thumbnail use the fallback handling logic in vips_icc_*() instead of having our own --- libvips/resample/thumbnail.c | 64 +++++++++--------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/libvips/resample/thumbnail.c b/libvips/resample/thumbnail.c index babf8233..21512a43 100644 --- a/libvips/resample/thumbnail.c +++ b/libvips/resample/thumbnail.c @@ -368,10 +368,9 @@ vips_thumbnail_build( VipsObject *object ) in->BandFmt == VIPS_FORMAT_USHORT) && (vips_image_get_typeof( in, VIPS_META_ICC_NAME ) || thumbnail->import_profile) ) { - if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) - g_info( "importing with embedded profile" ); - else - g_info( "importing with profile %s", + g_info( "importing to XYZ PCS" ); + if( thumbnail->import_profile ) + g_info( "fallback input profile %s", thumbnail->import_profile ); if( vips_icc_import( in, &t[1], @@ -458,52 +457,19 @@ vips_thumbnail_build( VipsObject *object ) else if( thumbnail->export_profile && (vips_image_get_typeof( in, VIPS_META_ICC_NAME ) || thumbnail->import_profile) ) { - VipsImage *out; + g_info( "transforming to %s", thumbnail->export_profile ); + if( thumbnail->import_profile ) + g_info( "fallback input profile %s", + thumbnail->import_profile ); - g_info( "exporting with profile %s", thumbnail->export_profile ); - - /* We first try with the embedded profile, if any, then if - * that fails try again with the supplied fallback profile. - */ - out = NULL; - if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { - g_info( "importing with embedded profile" ); - - if( vips_icc_transform( in, &t[7], - thumbnail->export_profile, - "intent", thumbnail->intent, - "embedded", TRUE, - NULL ) ) { - g_warning( _( "unable to import with " - "embedded profile: %s" ), - vips_error_buffer() ); - - vips_error_clear(); - } - else - out = t[7]; - } - - if( !out && - thumbnail->import_profile ) { - g_info( "importing with fallback profile" ); - - if( vips_icc_transform( in, &t[7], - thumbnail->export_profile, - "input_profile", thumbnail->import_profile, - "intent", thumbnail->intent, - "embedded", FALSE, - NULL ) ) - return( -1 ); - - out = t[7]; - } - - /* If the embedded profile failed and there's no fallback or - * the fallback failed, out will still be NULL. - */ - if( out ) - in = out; + if( vips_icc_transform( in, &t[7], + thumbnail->export_profile, + "input_profile", thumbnail->import_profile, + "intent", thumbnail->intent, + "embedded", TRUE, + NULL ) ) + return( -1 ); + in = t[7]; } if( thumbnail->auto_rotate &&