Skip to content

Commit cf1228b

Browse files
committed
fix page_height arg for tiffsave
it wasn't wired up, thanks @jacopoabramo see libvips/pyvips#277
1 parent 5e7e914 commit cf1228b

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

libvips/foreign/pforeign.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ int vips__tiff_write( VipsImage *in, const char *filename,
6969
gboolean lossless,
7070
VipsForeignDzDepth depth,
7171
gboolean subifd,
72-
gboolean premultiply );
72+
gboolean premultiply,
73+
int page_height );
7374

7475
int vips__tiff_write_buf( VipsImage *in,
7576
void **obuf, size_t *olen,
@@ -89,7 +90,8 @@ int vips__tiff_write_buf( VipsImage *in,
8990
gboolean lossless,
9091
VipsForeignDzDepth depth,
9192
gboolean subifd,
92-
gboolean premultiply );
93+
gboolean premultiply,
94+
int page_height );
9395

9496
gboolean vips__istiff_source( VipsSource *source );
9597
gboolean vips__istifftiled_source( VipsSource *source );

libvips/foreign/tiffsave.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ vips_foreign_save_tiff_file_build( VipsObject *object )
438438
tiff->lossless,
439439
tiff->depth,
440440
tiff->subifd,
441-
tiff->premultiply ) )
441+
tiff->premultiply,
442+
save->page_height ) )
442443
return( -1 );
443444

444445
return( 0 );
@@ -512,7 +513,8 @@ vips_foreign_save_tiff_buffer_build( VipsObject *object )
512513
tiff->lossless,
513514
tiff->depth,
514515
tiff->subifd,
515-
tiff->premultiply ) )
516+
tiff->premultiply,
517+
save->page_height ) )
516518
return( -1 );
517519

518520
blob = vips_blob_new( (VipsCallbackFn) vips_area_free_cb, obuf, olen );

libvips/foreign/vips2tiff.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,8 @@ wtiff_new( VipsImage *input, const char *filename,
11431143
gboolean lossless,
11441144
VipsForeignDzDepth depth,
11451145
gboolean subifd,
1146-
gboolean premultiply )
1146+
gboolean premultiply,
1147+
int page_height )
11471148
{
11481149
Wtiff *wtiff;
11491150

@@ -1178,7 +1179,7 @@ wtiff_new( VipsImage *input, const char *filename,
11781179
wtiff->subifd = subifd;
11791180
wtiff->premultiply = premultiply;
11801181
wtiff->toilet_roll = FALSE;
1181-
wtiff->page_height = vips_image_get_page_height( input );
1182+
wtiff->page_height = page_height;
11821183
wtiff->page_number = 0;
11831184
wtiff->n_pages = 1;
11841185
wtiff->image_height = input->Ysize;
@@ -1195,9 +1196,13 @@ wtiff_new( VipsImage *input, const char *filename,
11951196
if( wtiff->ready->Type == VIPS_INTERPRETATION_XYZ )
11961197
wtiff->compression = COMPRESSION_SGILOG;
11971198

1198-
/* Multipage image?
1199+
/* Multipage image? 0 is the default for this argument.
11991200
*/
1200-
if( wtiff->page_height < wtiff->ready->Ysize ) {
1201+
if( wtiff->page_height == 0 )
1202+
wtiff->page_height = vips_image_get_page_height( input );
1203+
if( wtiff->page_height > 0 &&
1204+
wtiff->page_height < wtiff->ready->Ysize &&
1205+
wtiff->ready->Ysize % wtiff->page_height == 0 ) {
12011206
#ifdef DEBUG
12021207
printf( "wtiff_new: detected toilet roll image, "
12031208
"page-height=%d\n",
@@ -2294,7 +2299,8 @@ vips__tiff_write( VipsImage *input, const char *filename,
22942299
gboolean lossless,
22952300
VipsForeignDzDepth depth,
22962301
gboolean subifd,
2297-
gboolean premultiply )
2302+
gboolean premultiply,
2303+
int page_height )
22982304
{
22992305
Wtiff *wtiff;
23002306

@@ -2309,7 +2315,7 @@ vips__tiff_write( VipsImage *input, const char *filename,
23092315
tile, tile_width, tile_height, pyramid, bitdepth,
23102316
miniswhite, resunit, xres, yres, bigtiff, rgbjpeg,
23112317
properties, strip, region_shrink, level, lossless, depth,
2312-
subifd, premultiply )) )
2318+
subifd, premultiply, page_height )) )
23132319
return( -1 );
23142320

23152321
if( vips_sink_disc( wtiff->ready, wtiff_sink_disc_strip, wtiff ) ) {
@@ -2341,7 +2347,8 @@ vips__tiff_write_buf( VipsImage *input,
23412347
gboolean lossless,
23422348
VipsForeignDzDepth depth,
23432349
gboolean subifd,
2344-
gboolean premultiply )
2350+
gboolean premultiply,
2351+
int page_height )
23452352
{
23462353
Wtiff *wtiff;
23472354

@@ -2352,7 +2359,7 @@ vips__tiff_write_buf( VipsImage *input,
23522359
tile, tile_width, tile_height, pyramid, bitdepth,
23532360
miniswhite, resunit, xres, yres, bigtiff, rgbjpeg,
23542361
properties, strip, region_shrink, level, lossless, depth,
2355-
subifd, premultiply )) )
2362+
subifd, premultiply, page_height )) )
23562363
return( -1 );
23572364

23582365
wtiff->obuf = obuf;

0 commit comments

Comments
 (0)