Merge branch 'master' into add-icc-fallbacks

This commit is contained in:
John Cupitt 2019-01-11 09:20:13 +00:00
commit 0dcb2d1ef2

View File

@ -1067,10 +1067,10 @@ write_vips( Write *write,
VIPS_RINT( in->Xres * 1000 ), VIPS_RINT( in->Yres * 1000 ),
PNG_RESOLUTION_METER );
/* Set ICC Profile.
/* Metadata
*/
if( profile &&
!strip ) {
if( !strip ) {
if( profile ) {
VipsBlob *blob;
if( vips_profile_load( profile, &blob, NULL ) )
@ -1080,59 +1080,58 @@ write_vips( Write *write,
const void *data = vips_blob_get( blob, &length );
#ifdef DEBUG
printf( "write_vips: "
"attaching %zd bytes of ICC profile\n",
length );
printf( "write_vips: attaching %zd bytes "
"of ICC profile\n", length );
#endif /*DEBUG*/
png_set_iCCP( write->pPng, write->pInfo,
"icc", PNG_COMPRESSION_TYPE_BASE,
data, length );
vips_area_unref( (VipsArea *) blob );
}
}
else if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) {
const void *data;
size_t length;
if( vips_image_get_blob( in, VIPS_META_ICC_NAME,
&data, &length ) )
return( -1 );
#ifdef DEBUG
printf( "write_vips: attaching %zd bytes "
"of ICC profile\n", length );
#endif /*DEBUG*/
png_set_iCCP( write->pPng, write->pInfo, "icc",
PNG_COMPRESSION_TYPE_BASE, data, length );
vips_area_unref( (VipsArea *) blob );
}
}
else if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) &&
!strip ) {
const void *data;
size_t size;
if( vips_image_get_blob( in, VIPS_META_ICC_NAME,
&data, &size ) )
return( -1 );
#ifdef DEBUG
printf( "write_vips: attaching %zd bytes of ICC profile\n",
size );
#endif /*DEBUG*/
png_set_iCCP( write->pPng, write->pInfo, "icc",
PNG_COMPRESSION_TYPE_BASE, data, size );
}
if( vips_image_get_typeof( in, VIPS_META_XMP_NAME ) ) {
const void *data;
size_t size;
size_t length;
char *str;
/* XMP is attached as a BLOB with no null-termination. We
* must re-add this.
/* XMP is attached as a BLOB with no null-termination.
* We must re-add this.
*/
if( vips_image_get_blob( in,
VIPS_META_XMP_NAME, &data, &size ) )
VIPS_META_XMP_NAME, &data, &length ) )
return( -1 );
str = g_malloc( size + 1 );
vips_strncpy( str, data, size + 1 );
str = g_malloc( length + 1 );
vips_strncpy( str, data, length + 1 );
vips__png_set_text( write->pPng, write->pInfo,
"XML:com.adobe.xmp", str );
g_free( str );
}
/* Set any "png-comment-xx-yyy" metadata items.
*/
if( vips_image_map( in,
write_png_comment, write ) )
return( -1 );
}
#ifdef HAVE_IMAGEQUANT
if( palette ) {