From df2b7c5430e787c54907461f1425bfcd9d65416a Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 7 Aug 2014 08:18:49 +0100 Subject: [PATCH] Prevent libpng verifying sRGB profiles Ensures PNG images saved by Photoshop work Mirrors the behaviour of Imagemagick --- libvips/foreign/vipspng.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 4145131a..0dee03d9 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -188,6 +188,12 @@ read_new( VipsImage *out, gboolean readbehind ) user_error_function, user_warning_function )) ) return( NULL ); +#ifdef PNG_SKIP_sRGB_CHECK_PROFILE + /* Prevent libpng (>=1.6.11) verifying sRGB profiles. + */ + png_set_option( read->pPng, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON ); +#endif /*PNG_SKIP_sRGB_CHECK_PROFILE*/ + /* Catch PNG errors from png_create_info_struct(). */ if( setjmp( png_jmpbuf( read->pPng ) ) ) @@ -717,6 +723,12 @@ write_new( VipsImage *in ) user_error_function, user_warning_function )) ) return( NULL ); +#ifdef PNG_SKIP_sRGB_CHECK_PROFILE + /* Prevent libpng (>=1.6.11) verifying sRGB profiles. + */ + png_set_option( write->pPng, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON ); +#endif /*PNG_SKIP_sRGB_CHECK_PROFILE*/ + /* Catch PNG errors from png_create_info_struct(). */ if( setjmp( png_jmpbuf( write->pPng ) ) )