diff --git a/ChangeLog b/ChangeLog index d747a365..a3637aeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ magic number [przemyslawpluta] - fix vipsthumbnail with pyr tiff [kleisauke] - text autofit could occasionally terminate early [levmorozov] - fewer warnings on tiffload [chregu] +- vips_resize() breaks aspect ratio and limits shrink to prevent <1px + dimensions [lovell] 21/9/18 started 8.8.0 - much faster smartcrop [lovell] diff --git a/libvips/resample/resize.c b/libvips/resample/resize.c index c22135ed..e99ca551 100644 --- a/libvips/resample/resize.c +++ b/libvips/resample/resize.c @@ -31,6 +31,8 @@ * 3/12/18 [edwjusti] * - disable the centre sampling offset for nearest upscale, since the * affine nearest interpolator is always centre + * 7/7/19 [lovell] + * - don't let either axis drop below 1px */ /* @@ -213,6 +215,11 @@ vips_resize_build( VipsObject *object ) hscale *= int_hshrink; } + /* Don't let either axis drop below 1 px. + */ + hscale = VIPS_MAX( hscale, 1.0 / in->Xsize ); + vscale = VIPS_MAX( vscale, 1.0 / in->Ysize ); + /* Any residual downsizing. */ if( vscale < 1.0 ) { @@ -424,6 +431,10 @@ vips_resize_init( VipsResize *resize ) * @vscale, that factor is used for the vertical scale and @scale for the * horizontal. * + * If either axis would drop below 1px in size, the shrink in that dimension + * is limited. This breaks the image aspect ratio, but prevents errors due to + * fractional pixel sizes. + * * This operation does not change xres or yres. The image resolution needs to * be updated by the application. *