enable bigtiff for large, uncompressed writes

if compression is off and the image is >4gb, make sure bigtiff is
enabled

this won't always work: if the image is just under the 4gb limit, it
could be pushed over the edge by a lot of metadata. And of course the
libtiff vips is using could be missing bigtiff support

see https://github.com/jcupitt/libvips/issues/591
This commit is contained in:
John Cupitt 2017-01-29 12:20:57 +00:00
parent 2b482fc2cf
commit e210411404
1 changed files with 16 additions and 0 deletions

View File

@ -168,6 +168,9 @@
* - use wchar_t TIFFOpen on Windows
* 14/10/16
* - add buffer output
* 29/1/17
* - enable bigtiff automatically for large, uncompressed writes, thanks
* AndreasSchmid1
*/
/*
@ -1028,6 +1031,19 @@ wtiff_new( VipsImage *im, const char *filename,
else
wtiff->tls = VIPS_IMAGE_SIZEOF_PEL( im ) * wtiff->tilew;
/* If compression is off and we're writing a >4gb image, automatically
* enable bigtiff.
*
* This won't always work. If the image data is just under 4gb but
* there's a lot of metadata, we could be pushed over the 4gb limit.
*/
if( wtiff->compression == COMPRESSION_NONE &&
VIPS_IMAGE_SIZEOF_IMAGE( wtiff->im ) > UINT_MAX &&
!wtiff->bigtiff ) {
g_warning( "%s", _( "image over 4gb, enabling bigtiff" ) );
wtiff->bigtiff = TRUE;
}
/* Build the pyramid framework.
*/
wtiff->layer = wtiff_layer_new( wtiff, NULL,