fix dzsave/vips2tiff for some image sizes

we were not clipping new strip size against image size, see

https://github.com/jcupitt/libvips/issues/300
This commit is contained in:
John Cupitt 2015-05-24 17:53:05 +01:00
parent 5f3d4c7971
commit 3451766004
4 changed files with 38 additions and 16 deletions

View File

@ -1,4 +1,5 @@
7/5/15 started 8.0.3 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 4/5/15 started 8.0.2
- fix a refcount error in C++ wrapper, thanks huskier - fix a refcount error in C++ wrapper, thanks huskier

View File

@ -9,7 +9,7 @@
<bookinfo> <bookinfo>
<title>VIPS Reference Manual</title> <title>VIPS Reference Manual</title>
<releaseinfo> <releaseinfo>
For VIPS 8.0.2. For VIPS 8.0.3.
The latest version of this documentation can be found on the The latest version of this documentation can be found on the
<ulink role="online-location" <ulink role="online-location"
url="http://www.vips.ecs.soton.ac.uk/index.php?title=Documentation">VIPS website</ulink>. url="http://www.vips.ecs.soton.ac.uk/index.php?title=Documentation">VIPS website</ulink>.

View File

@ -1330,8 +1330,10 @@ static int
strip_arrived( Layer *layer ) strip_arrived( Layer *layer )
{ {
VipsForeignSaveDz *dz = layer->dz; VipsForeignSaveDz *dz = layer->dz;
VipsRect new_strip; VipsRect new_strip;
VipsRect overlap; VipsRect overlap;
VipsRect image_area;
if( strip_save( layer ) ) if( strip_save( layer ) )
return( -1 ); return( -1 );
@ -1350,6 +1352,13 @@ strip_arrived( Layer *layer )
new_strip.top = layer->y - dz->overlap; new_strip.top = layer->y - dz->overlap;
new_strip.width = layer->image->Xsize; new_strip.width = layer->image->Xsize;
new_strip.height = dz->tile_size + 2 * dz->overlap; 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 ) if( (new_strip.height & 1) == 1 )
new_strip.height += 1; new_strip.height += 1;
@ -1375,14 +1384,16 @@ strip_arrived( Layer *layer )
&overlap, overlap.left, overlap.top ); &overlap, overlap.left, overlap.top );
} }
if( vips_region_buffer( layer->strip, &new_strip ) ) if( !vips_rect_isempty( &new_strip ) ) {
return( -1 ); if( vips_region_buffer( layer->strip, &new_strip ) )
return( -1 );
/* And copy back again. /* And copy back again.
*/ */
if( !vips_rect_isempty( &overlap ) ) if( !vips_rect_isempty( &overlap ) )
vips_region_copy( layer->copy, layer->strip, vips_region_copy( layer->copy, layer->strip,
&overlap, overlap.left, overlap.top ); &overlap, overlap.left, overlap.top );
}
return( 0 ); return( 0 );
} }

View File

@ -1236,6 +1236,7 @@ layer_strip_arrived( Layer *layer )
int result; int result;
VipsRect new_strip; VipsRect new_strip;
VipsRect overlap; VipsRect overlap;
VipsRect image_area;
if( write->tile ) if( write->tile )
result = layer_write_tile( write, layer, layer->strip ); result = layer_write_tile( write, layer, layer->strip );
@ -1245,7 +1246,7 @@ layer_strip_arrived( Layer *layer )
return( -1 ); return( -1 );
if( layer->below && if( layer->below &&
layer_strip_shrink( layer ) ) layer_strip_shrink( layer ) )
return( -1 ); return( -1 );
/* Position our strip down the image. /* Position our strip down the image.
@ -1258,6 +1259,13 @@ layer_strip_arrived( Layer *layer )
new_strip.top = layer->y; new_strip.top = layer->y;
new_strip.width = layer->image->Xsize; new_strip.width = layer->image->Xsize;
new_strip.height = write->tileh; 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 ) if( (new_strip.height & 1) == 1 )
new_strip.height += 1; new_strip.height += 1;
@ -1272,14 +1280,16 @@ layer_strip_arrived( Layer *layer )
&overlap, overlap.left, overlap.top ); &overlap, overlap.left, overlap.top );
} }
if( vips_region_buffer( layer->strip, &new_strip ) ) if( !vips_rect_isempty( &new_strip ) ) {
return( -1 ); if( vips_region_buffer( layer->strip, &new_strip ) )
return( -1 );
/* And copy back again. /* And copy back again.
*/ */
if( !vips_rect_isempty( &overlap ) ) if( !vips_rect_isempty( &overlap ) )
vips_region_copy( layer->copy, layer->strip, vips_region_copy( layer->copy, layer->strip,
&overlap, overlap.left, overlap.top ); &overlap, overlap.left, overlap.top );
}
return( 0 ); return( 0 );
} }