set n-subifds for tiff files

says how many subifds in the first page
This commit is contained in:
John Cupitt 2020-06-01 17:22:10 +01:00
parent d16f1e67dd
commit 460e1d0bf5
3 changed files with 23 additions and 2 deletions

View File

@ -304,6 +304,11 @@ typedef struct _RtiffHeader {
/* Scale factor to get absolute cd/m2 from XYZ.
*/
double stonits;
/* Number of subifds, if any.
*/
int subifd_count;
} RtiffHeader;
/* Scanline-type process function.
@ -1546,6 +1551,10 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out )
vips_image_set_int( out,
VIPS_META_PAGE_HEIGHT, rtiff->header.height );
if( rtiff->header.subifd_count > 0 )
vips_image_set_int( out,
VIPS_META_N_SUBIFDS, rtiff->header.subifd_count );
vips_image_set_int( out, VIPS_META_N_PAGES, rtiff->n_pages );
/* Even though we could end up serving tiled data, always hint
@ -2303,6 +2312,7 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header )
{
uint16 extra_samples_count;
uint16 *extra_samples_types;
toff_t *subifd_offsets;
if( !tfget32( rtiff->tiff, TIFFTAG_IMAGEWIDTH,
&header->width ) ||
@ -2400,6 +2410,11 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header )
header->separate = TRUE;
}
/* Stays zero if there's no SUBIFD.
*/
TIFFGetField( rtiff->tiff, TIFFTAG_SUBIFD,
&header->subifd_count, &subifd_offsets );
/* Tiles and strip images have slightly different fields.
*/
header->tiled = TIFFIsTiled( rtiff->tiff );

View File

@ -251,9 +251,8 @@
/* TODO:
*
* - have a layout enum rather than a bool
* - revise docs
* - revise tests
* - vipsthumbnail support for subifd pyramids
*/
/* Max number of alpha channels we allow.

View File

@ -150,6 +150,13 @@ extern "C" {
*/
#define VIPS_META_N_PAGES "n-pages"
/**
* VIPS_META_N_SUBIFDS:
*
* If set, the number of subifds in the first page of the file.
*/
#define VIPS_META_N_SUBIFDS "n-subifds"
guint64 vips_format_sizeof( VipsBandFormat format );
guint64 vips_format_sizeof_unsafe( VipsBandFormat format );