From 296eb8b54ec28e06976a274e5de86d33c0060a1b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 9 Aug 2014 17:14:49 +0100 Subject: [PATCH] fix pngload with libpng >=1.6.11 thaks Lovell --- ChangeLog | 1 + libvips/foreign/vipspng.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1eb41b48..5d72f281 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - vipsthumbnail shrinks to 1/2 window_size: faster and better quality - vipsthumbnail defaults to bicubic + nosharpen - better rounding behaviour for fixed-point bicubic reduces noise +- fix pngload with libpng >=1.6.11 4/7/14 started 7.40.4 - fix vips_rawsave_fd(), thanks aferrero2707 diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index c3a36f56..c8fefc7c 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -48,6 +48,8 @@ * still set color_type to alpha * 16/7/13 * - more robust error handling from libpng + * 9/8/14 + * - don't check profiles, helps with libpng >=1.6.11 */ /* @@ -188,6 +190,13 @@ 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 +726,13 @@ 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 ) ) )