copy photoshop data in tiff load/save

well, try anyway, it might work

see https://github.com/jcupitt/libvips/issues/332
This commit is contained in:
John Cupitt 2015-09-29 18:02:30 +01:00
parent 3889dcc3e2
commit 3b75d90174
4 changed files with 53 additions and 6 deletions

View File

@ -19,7 +19,7 @@
- vips_log(), vips_log10() are zero-avoiding
- better overlap handling for dzsave, thanks robclouth
- add @spacing option to vips_text()
- tiff loads and saves IPCT data
- tiff loads and saves IPCT and Photoshop data
7/5/15 started 8.0.3
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas

View File

@ -159,6 +159,7 @@
* fd during file read, handy for large numbers of input images
* 29/9/15
* - load IPCT metadata
* - load photoshop metadata
*/
/*
@ -1202,6 +1203,19 @@ parse_header( ReadTiff *rtiff, VipsImage *out )
(VipsCallbackFn) vips_free, data_copy, data_length );
}
/* Read any photoshop metadata.
*/
if( TIFFGetField( rtiff->tiff,
TIFFTAG_PHOTOSHOP, &data_length, &data ) ) {
void *data_copy;
if( !(data_copy = vips_malloc( NULL, data_length )) )
return( -1 );
memcpy( data_copy, data, data_length );
vips_image_set_blob( out, VIPS_META_PHOTOSHOP_NAME,
(VipsCallbackFn) vips_free, data_copy, data_length );
}
return( 0 );
}

View File

@ -155,6 +155,7 @@
* - add miniswhite option
* 29/9/15
* - try to write IPCT metadata
* - try to write photoshop metadata
*/
/*
@ -473,7 +474,29 @@ write_embed_ipct( Write *write, TIFF *tif )
TIFFSetField( tif, TIFFTAG_RICHTIFFIPTC, data_length, data );
#ifdef DEBUG
printf( "vips2tiff: attached XMP from meta\n" );
printf( "vips2tiff: attached IPCT from meta\n" );
#endif /*DEBUG*/
return( 0 );
}
/* Embed any XMP metadata.
*/
static int
write_embed_photoshop( Write *write, TIFF *tif )
{
void *data;
size_t data_length;
if( !vips_image_get_typeof( write->im, VIPS_META_PHOTOSHOP_NAME ) )
return( 0 );
if( vips_image_get_blob( write->im, VIPS_META_PHOTOSHOP_NAME,
&data, &data_length ) )
return( -1 );
TIFFSetField( tif, TIFFTAG_PHOTOSHOP, data_length, data );
#ifdef DEBUG
printf( "vips2tiff: attached photoshop data from meta\n" );
#endif /*DEBUG*/
return( 0 );
@ -514,7 +537,8 @@ write_tiff_header( Write *write, Layer *layer )
if( write_embed_profile( write, tif ) ||
write_embed_xmp( write, tif ) ||
write_embed_ipct( write, tif ) )
write_embed_ipct( write, tif ) ||
write_embed_photoshop( write, tif ) )
return( -1 );
/* And colour fields.
@ -1461,7 +1485,8 @@ write_copy_tiff( Write *write, TIFF *out, TIFF *in )
*/
if( write_embed_profile( write, out ) ||
write_embed_xmp( write, out ) ||
write_embed_ipct( write, out ) )
write_embed_ipct( write, out ) ||
write_embed_photoshop( write, out ) )
return( -1 );
buf = vips_malloc( NULL, TIFFTileSize( in ) );

View File

@ -48,17 +48,25 @@ extern "C" {
/**
* VIPS_META_XMP_NAME:
*
* The name that JPEG read and write operations use for the image's XMP data.
* The name that read and write operations use for the image's XMP data.
*/
#define VIPS_META_XMP_NAME "xmp-data"
/**
* VIPS_META_IPCT_NAME:
*
* The name that JPEG read and write operations use for the image's IPCT data.
* The name that read and write operations use for the image's IPCT data.
*/
#define VIPS_META_IPCT_NAME "ipct-data"
/**
* VIPS_META_PHOTOSHOP_NAME:
*
* The name that TIFF read and write operations use for the image's
* TIFFTAG_PHOTOSHOP data.
*/
#define VIPS_META_PHOTOSHOP_NAME "photoshop-data"
/**
* VIPS_META_ICC_NAME:
*