limit resize if shrink would drop axis <1px

vips_resize() will break the aspect ratio and limit resize on an axis if
it would result in an image of less than 1px on that axis

see https://github.com/lovell/sharp/issues/1782#issuecomment-508921306
This commit is contained in:
John Cupitt 2019-07-07 10:19:33 +01:00
parent 26100041e7
commit f45f0ecef4
2 changed files with 13 additions and 0 deletions

View File

@ -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]

View File

@ -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.
*