diff --git a/ChangeLog b/ChangeLog index 2aac9d21..5b3daac1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 7/5/15 started 8.0.3 +- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas 4/5/15 started 8.0.2 - fix a refcount error in C++ wrapper, thanks huskier diff --git a/doc/libvips-docs.xml b/doc/libvips-docs.xml index 8732aa0d..53c2c400 100644 --- a/doc/libvips-docs.xml +++ b/doc/libvips-docs.xml @@ -9,7 +9,7 @@ VIPS Reference Manual - For VIPS 8.0.2. + For VIPS 8.0.3. The latest version of this documentation can be found on the VIPS website. diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index 37bb10de..eff1a6ab 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -1330,8 +1330,10 @@ static int strip_arrived( Layer *layer ) { VipsForeignSaveDz *dz = layer->dz; + VipsRect new_strip; VipsRect overlap; + VipsRect image_area; if( strip_save( layer ) ) return( -1 ); @@ -1350,6 +1352,13 @@ strip_arrived( Layer *layer ) new_strip.top = layer->y - dz->overlap; new_strip.width = layer->image->Xsize; new_strip.height = dz->tile_size + 2 * dz->overlap; + + image_area.left = 0; + image_area.top = 0; + image_area.width = layer->image->Xsize; + image_area.height = layer->image->Ysize; + vips_rect_intersectrect( &new_strip, &image_area, &new_strip ); + if( (new_strip.height & 1) == 1 ) new_strip.height += 1; @@ -1375,14 +1384,16 @@ strip_arrived( Layer *layer ) &overlap, overlap.left, overlap.top ); } - if( vips_region_buffer( layer->strip, &new_strip ) ) - return( -1 ); + if( !vips_rect_isempty( &new_strip ) ) { + if( vips_region_buffer( layer->strip, &new_strip ) ) + return( -1 ); - /* And copy back again. - */ - if( !vips_rect_isempty( &overlap ) ) - vips_region_copy( layer->copy, layer->strip, - &overlap, overlap.left, overlap.top ); + /* And copy back again. + */ + if( !vips_rect_isempty( &overlap ) ) + vips_region_copy( layer->copy, layer->strip, + &overlap, overlap.left, overlap.top ); + } return( 0 ); } diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index efc19bd6..b1e52112 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1236,6 +1236,7 @@ layer_strip_arrived( Layer *layer ) int result; VipsRect new_strip; VipsRect overlap; + VipsRect image_area; if( write->tile ) result = layer_write_tile( write, layer, layer->strip ); @@ -1245,7 +1246,7 @@ layer_strip_arrived( Layer *layer ) return( -1 ); if( layer->below && - layer_strip_shrink( layer ) ) + layer_strip_shrink( layer ) ) return( -1 ); /* Position our strip down the image. @@ -1258,6 +1259,13 @@ layer_strip_arrived( Layer *layer ) new_strip.top = layer->y; new_strip.width = layer->image->Xsize; new_strip.height = write->tileh; + + image_area.left = 0; + image_area.top = 0; + image_area.width = layer->image->Xsize; + image_area.height = layer->image->Ysize; + vips_rect_intersectrect( &new_strip, &image_area, &new_strip ); + if( (new_strip.height & 1) == 1 ) new_strip.height += 1; @@ -1272,14 +1280,16 @@ layer_strip_arrived( Layer *layer ) &overlap, overlap.left, overlap.top ); } - if( vips_region_buffer( layer->strip, &new_strip ) ) - return( -1 ); + if( !vips_rect_isempty( &new_strip ) ) { + if( vips_region_buffer( layer->strip, &new_strip ) ) + return( -1 ); - /* And copy back again. - */ - if( !vips_rect_isempty( &overlap ) ) - vips_region_copy( layer->copy, layer->strip, - &overlap, overlap.left, overlap.top ); + /* And copy back again. + */ + if( !vips_rect_isempty( &overlap ) ) + vips_region_copy( layer->copy, layer->strip, + &overlap, overlap.left, overlap.top ); + } return( 0 ); }