From 83e36880dae6ae1f5e56713d5d7ec3d8b3e31401 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 31 Dec 2017 10:38:35 +0000 Subject: [PATCH] more compat for older IPCT code add IPTC data under the name "ipct-data" as well --- libvips/foreign/jpeg2vips.c | 15 ++++++++++++--- libvips/foreign/tiff2vips.c | 12 ++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index 6fcd4a11..eb59427e 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -471,10 +471,19 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out ) /* Possible IPTC data block. */ if( p->data_length > 5 && - vips_isprefix( "Photo", (char *) p->data ) && - attach_blob( out, VIPS_META_IPTC_NAME, + vips_isprefix( "Photo", (char *) p->data ) ) { + if( attach_blob( out, VIPS_META_IPTC_NAME, p->data, p->data_length ) ) - return( -1 ); + return( -1 ); + + /* Older versions of libvips used this misspelt + * name :-( attach under this name too for + * compatibility. + */ + if( attach_blob( out, "ipct-data", + p->data, p->data_length ) ) + return( -1 ); + } break; default: diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index bd9688b4..0f3e5bdb 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -1291,8 +1291,7 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) data_length ) { void *data_copy; - /* For no very good reason, libtiff stores IPTC as an array of - * long, not byte. + /* libtiff stores IPTC as an array of long, not byte. */ data_length *= 4; @@ -1301,6 +1300,15 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) memcpy( data_copy, data, data_length ); vips_image_set_blob( out, VIPS_META_IPTC_NAME, (VipsCallbackFn) vips_free, data_copy, data_length ); + + /* Older versions of libvips used this misspelt name :-( attach + * under this name too for compatibility. + */ + if( !(data_copy = vips_malloc( NULL, data_length )) ) + return( -1 ); + memcpy( data_copy, data, data_length ); + vips_image_set_blob( out, "ipct-data", + (VipsCallbackFn) vips_free, data_copy, data_length ); } /* Read any photoshop metadata.