diff --git a/ChangeLog b/ChangeLog index a4713f2e..af3189b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ - flood fill could stop half-way for some very complex shapes - better handling of unaligned reads in multipage tiffs [petoor] - mark old --delete option to vipsthumbnail as deprecated [UweOhse] +- png save with a bad ICC profile just gives a warning 24/4/20 started 8.9.3 - better iiif tile naming [IllyaMoskvin] diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index ead58bf7..1d9d6330 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -77,6 +77,8 @@ * - restart after minimise * 14/10/19 * - revise for connection IO + * 11/5/20 + * - only warn for saving bad profiles, don't fail */ /* @@ -1047,10 +1049,28 @@ write_vips( Write *write, "of ICC profile\n", length ); #endif /*DEBUG*/ - png_set_iCCP( write->pPng, write->pInfo, "icc", - PNG_COMPRESSION_TYPE_BASE, - (void *) data, length ); + /* We need to ignore any errors from png_set_iCCP() + * since we want to drop incompatible profiles rather + * than simply failing. + */ + if( setjmp( png_jmpbuf( write->pPng ) ) ) { + /* Silent ignore of error. + */ + g_warning( "bad ICC profile not saved" ); + } + else { + /* This will jump back to the line above on + * error. + */ + png_set_iCCP( write->pPng, write->pInfo, "icc", + PNG_COMPRESSION_TYPE_BASE, + (void *) data, length ); + } + /* And restore the setjmp. + */ + if( setjmp( png_jmpbuf( write->pPng ) ) ) + return( -1 ); } if( vips_image_get_typeof( in, VIPS_META_XMP_NAME ) ) {