From 9690bd40e9f8057438703e784fb95802a2794a17 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 9 Jan 2013 11:33:13 +0000 Subject: [PATCH] better icc profile write for vips2png tests for icc profile presence before reading, to avoid polluting the error log --- libvips/foreign/vipspng.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 40f83d6f..0fce2bb0 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -103,7 +103,7 @@ static void user_error_function( png_structp png_ptr, png_const_charp error_msg ) { - vips_error( "png2vips", "%s", error_msg ); + vips_error( "vipspng", "%s", error_msg ); /* This function must not return, or the default error handler will be * invoked. @@ -114,7 +114,7 @@ user_error_function( png_structp png_ptr, png_const_charp error_msg ) static void user_warning_function( png_structp png_ptr, png_const_charp warning_msg ) { - vips_error( "png2vips", "%s", warning_msg ); + vips_error( "vipspng", "%s", warning_msg ); } /* What we track during a PNG read. @@ -611,8 +611,6 @@ write_vips( Write *write, int compress, int interlace ) int color_type; int interlace_type; int i, nb_passes; - void *profile; - size_t profile_length; g_assert( in->BandFmt == VIPS_FORMAT_UCHAR || in->BandFmt == VIPS_FORMAT_USHORT ); @@ -668,8 +666,14 @@ write_vips( Write *write, int compress, int interlace ) /* Set ICC Profile. */ - if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, - &profile, &profile_length ) ) { + if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { + void *profile; + size_t profile_length; + + if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, + &profile, &profile_length ) ) + return( -1 ); + #ifdef DEBUG printf( "write_vips: attaching %zd bytes of ICC profile\n", profile_length );