diff --git a/ChangeLog b/ChangeLog index 3bd53e03..c98df350 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ - vipsthumbnail has --rotate auto-rotate option - removed embedded thumbnail reader from vipsthumbnail: embedded thumbnails are too unlike the main image +- fix to vipsthumbnail --crop, thanks Alessandro 6/3/14 started 7.38.6 - grey ramp minimum was wrong diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index dc130765..5f5625ef 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -199,13 +199,19 @@ calculate_shrink( VipsImage *im, double *residual ) int shrink = floor( factor2 ); if( residual ) { - /* Width after int shrink. + /* Size after int shrink. We have to try with both axes since + * if they are very different sizes we'll see different + * rounding errors. */ int iwidth = width / shrink; + int iheight = height / shrink; /* Therefore residual scale factor is. */ - *residual = (width / factor) / iwidth; + double hresidual = (width / factor) / iwidth; + double vresidual = (height / factor) / iheight; + + *residual = VIPS_MAX( hresidual, vresidual ); } return( shrink );