From 7073b8fb172f6421795a3dc9e54351158af4c85b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 4 Jan 2019 07:30:47 +0000 Subject: [PATCH] start adding fallbacks for savers not finished though --- libvips/colour/CMYK2XYZ.c | 9 +++++++++ libvips/foreign/foreign.c | 15 +++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libvips/colour/CMYK2XYZ.c b/libvips/colour/CMYK2XYZ.c index 42f184ea..5febc065 100644 --- a/libvips/colour/CMYK2XYZ.c +++ b/libvips/colour/CMYK2XYZ.c @@ -126,6 +126,15 @@ vips__fallback_profile_set( const char *name, VipsImage *image ) size_t data_length; unsigned char *data; + /* Things like jpegsave let you save with no profile by setting + * "none" as a profile name. + */ + if( strcmp( name, "none" ) == 0 ) { + vips_image_remove( image, VIPS_META_ICC_NAME ); + + return( 0 ); + } + /* Already a profile? Do nothing. We could remove and replace non-CMYK * profiles I guess. */ diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 651fea81..f6c81e3b 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -1259,15 +1259,6 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, g_object_unref( in ); in = out; - - /* We've imported to PCS, we must remove the embedded profile, - * since it no longer matches the image. - * - * For example, when converting CMYK JPG to RGB PNG, we need - * to remove the CMYK profile on import, or the png writer will - * try to attach it when we write the image as RGB. - */ - vips_image_remove( in, VIPS_META_ICC_NAME ); } /* If this is something other than CMYK or RAD, eg. maybe a LAB image, @@ -1519,11 +1510,11 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, */ if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { const void *data; - size_t size; + size_t length; if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, - &data, &size ) && - !vips_icc_is_compatible_profile( in, data, size ) ) + &data, &length ) && + !vips_icc_is_compatible_profile( in, data, length ) ) vips_image_remove( in, VIPS_META_ICC_NAME ); }