fix page_height arg for tiffsave

it wasn't wired up, thanks @jacopoabramo

see https://github.com/libvips/pyvips/issues/277
This commit is contained in:
John Cupitt 2021-10-20 10:18:22 +01:00
parent 5e7e914b06
commit cf1228b927
3 changed files with 23 additions and 12 deletions

View File

@ -69,7 +69,8 @@ int vips__tiff_write( VipsImage *in, const char *filename,
gboolean lossless,
VipsForeignDzDepth depth,
gboolean subifd,
gboolean premultiply );
gboolean premultiply,
int page_height );
int vips__tiff_write_buf( VipsImage *in,
void **obuf, size_t *olen,
@ -89,7 +90,8 @@ int vips__tiff_write_buf( VipsImage *in,
gboolean lossless,
VipsForeignDzDepth depth,
gboolean subifd,
gboolean premultiply );
gboolean premultiply,
int page_height );
gboolean vips__istiff_source( VipsSource *source );
gboolean vips__istifftiled_source( VipsSource *source );

View File

@ -438,7 +438,8 @@ vips_foreign_save_tiff_file_build( VipsObject *object )
tiff->lossless,
tiff->depth,
tiff->subifd,
tiff->premultiply ) )
tiff->premultiply,
save->page_height ) )
return( -1 );
return( 0 );
@ -512,7 +513,8 @@ vips_foreign_save_tiff_buffer_build( VipsObject *object )
tiff->lossless,
tiff->depth,
tiff->subifd,
tiff->premultiply ) )
tiff->premultiply,
save->page_height ) )
return( -1 );
blob = vips_blob_new( (VipsCallbackFn) vips_area_free_cb, obuf, olen );

View File

@ -1143,7 +1143,8 @@ wtiff_new( VipsImage *input, const char *filename,
gboolean lossless,
VipsForeignDzDepth depth,
gboolean subifd,
gboolean premultiply )
gboolean premultiply,
int page_height )
{
Wtiff *wtiff;
@ -1178,7 +1179,7 @@ wtiff_new( VipsImage *input, const char *filename,
wtiff->subifd = subifd;
wtiff->premultiply = premultiply;
wtiff->toilet_roll = FALSE;
wtiff->page_height = vips_image_get_page_height( input );
wtiff->page_height = page_height;
wtiff->page_number = 0;
wtiff->n_pages = 1;
wtiff->image_height = input->Ysize;
@ -1195,9 +1196,13 @@ wtiff_new( VipsImage *input, const char *filename,
if( wtiff->ready->Type == VIPS_INTERPRETATION_XYZ )
wtiff->compression = COMPRESSION_SGILOG;
/* Multipage image?
/* Multipage image? 0 is the default for this argument.
*/
if( wtiff->page_height < wtiff->ready->Ysize ) {
if( wtiff->page_height == 0 )
wtiff->page_height = vips_image_get_page_height( input );
if( wtiff->page_height > 0 &&
wtiff->page_height < wtiff->ready->Ysize &&
wtiff->ready->Ysize % wtiff->page_height == 0 ) {
#ifdef DEBUG
printf( "wtiff_new: detected toilet roll image, "
"page-height=%d\n",
@ -2294,7 +2299,8 @@ vips__tiff_write( VipsImage *input, const char *filename,
gboolean lossless,
VipsForeignDzDepth depth,
gboolean subifd,
gboolean premultiply )
gboolean premultiply,
int page_height )
{
Wtiff *wtiff;
@ -2309,7 +2315,7 @@ vips__tiff_write( VipsImage *input, const char *filename,
tile, tile_width, tile_height, pyramid, bitdepth,
miniswhite, resunit, xres, yres, bigtiff, rgbjpeg,
properties, strip, region_shrink, level, lossless, depth,
subifd, premultiply )) )
subifd, premultiply, page_height )) )
return( -1 );
if( vips_sink_disc( wtiff->ready, wtiff_sink_disc_strip, wtiff ) ) {
@ -2341,7 +2347,8 @@ vips__tiff_write_buf( VipsImage *input,
gboolean lossless,
VipsForeignDzDepth depth,
gboolean subifd,
gboolean premultiply )
gboolean premultiply,
int page_height )
{
Wtiff *wtiff;
@ -2352,7 +2359,7 @@ vips__tiff_write_buf( VipsImage *input,
tile, tile_width, tile_height, pyramid, bitdepth,
miniswhite, resunit, xres, yres, bigtiff, rgbjpeg,
properties, strip, region_shrink, level, lossless, depth,
subifd, premultiply )) )
subifd, premultiply, page_height )) )
return( -1 );
wtiff->obuf = obuf;