diff --git a/ChangeLog b/ChangeLog index ed4b46b9..539d7017 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ - vipsthumbnail uses vips_premultiply() for better alpha quality - vips_copy() can turn 1xN or Nx1 M-band images into MxN one-band images +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 - better C++ api test 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 ); }