more compat for older IPCT code

add IPTC data under the name "ipct-data" as well
This commit is contained in:
John Cupitt 2017-12-31 10:38:35 +00:00
parent 77287a938f
commit 83e36880da
2 changed files with 22 additions and 5 deletions

View File

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

View File

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