Nono.MA

[Solved] Mogrify Resize Image using Nearest Neighbors

LAST UPDATED FEBRUARY 5, 2022

To avoid ImageMagick from interpolating pixels when you want a sharp resize method (equivalent to PIL's Image.NEAREST_NEIGHBOR) you can use mogrify and set the -filter to point.

With mogrify

# Assuming we're upscaling an image smaller than 2000x2000 pixels
mogrify \
  -resize 2000x2000 \
  -filter point image.png

With convert

convert in.png \
  -interpolate Nearest \
  -filter point \
  -resize 800% out.png

Code