From 4b51a9d61ff0b144fd9190c91fb1aa7d3f07c2ec Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 25 Nov 2014 11:43:48 +0000 Subject: [PATCH] don't strip profiles in XYZ2scRGB see https://github.com/lovell/sharp/issues/125 --- ChangeLog | 1 + libvips/colour/XYZ2scRGB.c | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4b0739a..946794aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - better pbm (one bit) load, better pfm (float) load/save - added pbm (one bit) save - changed vips_gaussblur() parameters, sorry +- fixed XYZ2scRGB profile handling, thanks Lovell 25/7/14 started 7.41.0 - start working on --disable-deprecated diff --git a/libvips/colour/XYZ2scRGB.c b/libvips/colour/XYZ2scRGB.c index 22bacaab..38bf4b4f 100644 --- a/libvips/colour/XYZ2scRGB.c +++ b/libvips/colour/XYZ2scRGB.c @@ -4,6 +4,8 @@ * - from Yxy2XYZ.c * 1/7/13 * - remove any ICC profile + * 25/11/14 + * - oh argh, revert the above */ /* @@ -50,20 +52,21 @@ typedef VipsColourSpaceClass VipsXYZ2scRGBClass; G_DEFINE_TYPE( VipsXYZ2scRGB, vips_XYZ2scRGB, VIPS_TYPE_COLOUR_SPACE ); -static int -vips_XYZ2scRGB_build( VipsObject *object ) -{ - if( VIPS_OBJECT_CLASS( vips_XYZ2scRGB_parent_class )->build( object ) ) - return( -1 ); +/* We used to have the comment: - /* We've converted to sRGB without a profile. We must remove any ICC + * We've converted to sRGB without a profile. We must remove any ICC * profile left over from import or there will be a mismatch between * pixel values and the attached profile. - */ - vips_image_remove( VIPS_COLOUR( object )->out, VIPS_META_ICC_NAME ); - return( 0 ); -} + But this isn't right, we often call things sRGB that we know are not true + sRGB, for example: + + vips sharpen k2.jpg x.jpg + + sharpen will treat k2 as being in sRGB space even if that image has a + profile. If we drop the profile, x.jpg is suddenly untagged. + + */ void vips_XYZ2scRGB_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) @@ -100,7 +103,6 @@ vips_XYZ2scRGB_class_init( VipsXYZ2scRGBClass *class ) object_class->nickname = "XYZ2scRGB"; object_class->description = _( "transform XYZ to scRGB" ); - object_class->build = vips_XYZ2scRGB_build; colour_class->process_line = vips_XYZ2scRGB_line; } @@ -119,7 +121,7 @@ vips_XYZ2scRGB_init( VipsXYZ2scRGB *XYZ2scRGB ) * @out: output image * @...: %NULL-terminated list of optional named arguments * - * Turn XYZ to Yxy. + * Turn XYZ to scRGB. * * Returns: 0 on success, -1 on error */