8

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:

  • to obtain what you want, you should disable interpolation. – Vincent Oct 22 '14 at 10:39
  • @Vincent I was under the impression that using Integer or Nearest should disable it. Is there another way? – jozxyqk Oct 22 '14 at 10:43
  • I seriously don't have a clue for imagemagick, but I know that I need to disable interpolation when I want a pixelated enlargement in Photoshop... :) – Vincent Oct 22 '14 at 10:45
  • Any number of reasons: the images could have been made/provided by someone else, the sample could have been produced by a different application, ... – Michael Schumacher Dec 21 '14 at 13:51
  • @DumbNic MichaelSchumacher is correct. I created it with gimp, but I want to use imagemagick for gui-less automation. – jozxyqk Dec 23 '14 at 6:33
15

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.

| improve this answer | |
  • 1
    ImageMagick can be funny sometimes - as when the doc shows non uppercase parameters but they must still be used as convert -list interpolate lists the what is available and it's all uppercase. Note the default is Bilinear. As you mention after a few tests I can't say it changes anything that I can see loll. There is mention that this is most important for distort/transform etc. Cheers! – user29318 Nov 21 '14 at 12:43
  • This did not work for me, however changing Nearest to Integer made it all work. Thank you for the -filter point hint! – Unapiedra Jan 19 '19 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.