@@ -1143,7 +1143,8 @@ wtiff_new( VipsImage *input, const char *filename,
1143
1143
gboolean lossless ,
1144
1144
VipsForeignDzDepth depth ,
1145
1145
gboolean subifd ,
1146
- gboolean premultiply )
1146
+ gboolean premultiply ,
1147
+ int page_height )
1147
1148
{
1148
1149
Wtiff * wtiff ;
1149
1150
@@ -1178,7 +1179,7 @@ wtiff_new( VipsImage *input, const char *filename,
1178
1179
wtiff -> subifd = subifd ;
1179
1180
wtiff -> premultiply = premultiply ;
1180
1181
wtiff -> toilet_roll = FALSE;
1181
- wtiff -> page_height = vips_image_get_page_height ( input ) ;
1182
+ wtiff -> page_height = page_height ;
1182
1183
wtiff -> page_number = 0 ;
1183
1184
wtiff -> n_pages = 1 ;
1184
1185
wtiff -> image_height = input -> Ysize ;
@@ -1195,9 +1196,13 @@ wtiff_new( VipsImage *input, const char *filename,
1195
1196
if ( wtiff -> ready -> Type == VIPS_INTERPRETATION_XYZ )
1196
1197
wtiff -> compression = COMPRESSION_SGILOG ;
1197
1198
1198
- /* Multipage image?
1199
+ /* Multipage image? 0 is the default for this argument.
1199
1200
*/
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 ) {
1201
1206
#ifdef DEBUG
1202
1207
printf ( "wtiff_new: detected toilet roll image, "
1203
1208
"page-height=%d\n" ,
@@ -2294,7 +2299,8 @@ vips__tiff_write( VipsImage *input, const char *filename,
2294
2299
gboolean lossless ,
2295
2300
VipsForeignDzDepth depth ,
2296
2301
gboolean subifd ,
2297
- gboolean premultiply )
2302
+ gboolean premultiply ,
2303
+ int page_height )
2298
2304
{
2299
2305
Wtiff * wtiff ;
2300
2306
@@ -2309,7 +2315,7 @@ vips__tiff_write( VipsImage *input, const char *filename,
2309
2315
tile , tile_width , tile_height , pyramid , bitdepth ,
2310
2316
miniswhite , resunit , xres , yres , bigtiff , rgbjpeg ,
2311
2317
properties , strip , region_shrink , level , lossless , depth ,
2312
- subifd , premultiply )) )
2318
+ subifd , premultiply , page_height )) )
2313
2319
return ( -1 );
2314
2320
2315
2321
if ( vips_sink_disc ( wtiff -> ready , wtiff_sink_disc_strip , wtiff ) ) {
@@ -2341,7 +2347,8 @@ vips__tiff_write_buf( VipsImage *input,
2341
2347
gboolean lossless ,
2342
2348
VipsForeignDzDepth depth ,
2343
2349
gboolean subifd ,
2344
- gboolean premultiply )
2350
+ gboolean premultiply ,
2351
+ int page_height )
2345
2352
{
2346
2353
Wtiff * wtiff ;
2347
2354
@@ -2352,7 +2359,7 @@ vips__tiff_write_buf( VipsImage *input,
2352
2359
tile , tile_width , tile_height , pyramid , bitdepth ,
2353
2360
miniswhite , resunit , xres , yres , bigtiff , rgbjpeg ,
2354
2361
properties , strip , region_shrink , level , lossless , depth ,
2355
- subifd , premultiply )) )
2362
+ subifd , premultiply , page_height )) )
2356
2363
return ( -1 );
2357
2364
2358
2365
wtiff -> obuf = obuf ;
0 commit comments