From 3b6bcef70073c4dbed873e1c7cad5c5a843666f1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 1 Jul 2013 09:23:09 +0100 Subject: [PATCH] strip ICC profile on conversion in xyz2srgb if we use the vips xys->srgb path (ie. not the lcms one) we must remove any ICC profile left over from import, otherwise we may have srgb pixels with a non-srgb profile --- ChangeLog | 1 + libvips/colour/XYZ2scRGB.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 74ec9b80..ec4b047a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 28/6/13 started 7.34.1 - fix morphological operators on non-uchar images +- remove any ICC profile when we use vips to go to srgb 7/6/13 started 7.34.0 - version bump diff --git a/libvips/colour/XYZ2scRGB.c b/libvips/colour/XYZ2scRGB.c index 1b2e4ac6..591489d3 100644 --- a/libvips/colour/XYZ2scRGB.c +++ b/libvips/colour/XYZ2scRGB.c @@ -2,6 +2,8 @@ * * 11/12/12 * - from Yxy2XYZ.c + * 1/7/13 + * - remove any ICC profile */ /* @@ -48,6 +50,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'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 ); +} + void vips_XYZ2scRGB_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) { @@ -83,6 +100,7 @@ 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; }