From f66afb78dac81a8650bcf227b4b7e9c80cd3d6c1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 25 Nov 2014 12:01:13 +0000 Subject: [PATCH] fix profile handling in XYZ2scRGB see https://github.com/lovell/sharp/issues/125 --- ChangeLog | 1 + libvips/colour/XYZ2scRGB.c | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc95d165..d0f38f8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 27/10/14 started 7.40.12 - better tiff detection (Lovell) - fix memleak in sharpen (Lovell) +- fix profile handling in XYZ2scRGB, thanks Lovell 8/10/14 started 7.40.11 - rework extra band handling for colour functions diff --git a/libvips/colour/XYZ2scRGB.c b/libvips/colour/XYZ2scRGB.c index cebd1e30..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; } @@ -117,8 +119,9 @@ vips_XYZ2scRGB_init( VipsXYZ2scRGB *XYZ2scRGB ) * vips_XYZ2scRGB: * @in: input image * @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 */