Advertisement


Nearest neighbour interpolation not working in ImageMagick


Question

I want to display an image and have the pixels big and clearly visible. As it's common to display scaled image with some form of smooth filtering, the best option is to scale up the image resolution without interpolation (i.e. nearest). I have quite a few and need automation, hence ImageMagick.

I'm certain I've done this before and hit the same problem, but this time Google isn't helping. I vaguely remember the order of the arguments can be quite important here but I've tried every permutation and the output is the same.

The following simply doesn't work. It resizes the image correctly but it's all blurry:

convert from.png -interpolate Nearest -resize 800% to.png

What am I missing?


Example:

I start with enter image description here

I get this enter image description here

But want this enter image description here


Related links:

2015/02/20
1
7
2/20/2015 6:04:00 PM

Silly me. I found a solution in my bash history. I needed to set -filter point.

convert from.png -interpolate Nearest -filter point -resize 800% to.png

The default filter appears to be Cubic for me. Interestingly, -interpolate Nearest doesn't seem to affect the output at all and may not be needed above. I'd love to know why and won't accept this as the answer.

2014/10/22
14
10/22/2014 11:42:00 AM