only warn on png save with a bad profile

Previously we failed. This is very ugly, but it seems to be the only
obvious way to fix this.

See https://github.com/libvips/libvips/issues/1578
This commit is contained in:
John Cupitt 2020-05-11 18:00:26 +01:00
parent 0c9f311f1e
commit b9385b9d35
2 changed files with 24 additions and 3 deletions

View File

@ -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]

View File

@ -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 ) ) {