From f5d76b42fc889d6db74f256a53a54d56b73a22a3 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 3 Dec 2018 17:13:57 +0000 Subject: [PATCH] fix centre sampling for non-int nearest upscale we were not disabling the input offset for NEAREST, whcih is always centre thanks edwjusti see https://github.com/lovell/sharp/issues/1479 --- libvips/resample/resize.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libvips/resample/resize.c b/libvips/resample/resize.c index fd5f4c37..c22135ed 100644 --- a/libvips/resample/resize.c +++ b/libvips/resample/resize.c @@ -28,6 +28,9 @@ * - make LINEAR and CUBIC adaptive * 25/11/17 * - deprecate --centre ... it's now always on, thanks tback + * 3/12/18 [edwjusti] + * - disable the centre sampling offset for nearest upscale, since the + * affine nearest interpolator is always centre */ /* @@ -241,9 +244,12 @@ vips_resize_build( VipsObject *object ) vips_resize_interpolate( resize->kernel ); /* Input displacement. For centre sampling, shift by 0.5 down - * and right. + * and right. Except if this is nearest, which is always + * centre. */ - const double id = 0.5; + const double id = + resize->kernel == VIPS_KERNEL_NEAREST ? + 0.0 : 0.5; VipsInterpolate *interpolate;