Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick resize without interpolation

I have a small pixel map original and want to resize it for better readability.

Using mogrify -resize 1600% I get an interpolated image: wrong.

What I'm trying to get is this: right.

Can this be done by ImageMagick or any other open source command line tool?

like image 822
Stef Avatar asked Sep 09 '15 16:09

Stef


3 Answers

I finally found the solution: using -scale instead of -resize does the trick. It is 'hidden' under the heading Scale - Minify with pixel averaging, therefore I overlooked it at first, searching for magnification instead of minification.

like image 63
Stef Avatar answered Nov 09 '22 02:11

Stef


This worked for me:

convert input.png -interpolate Integer -filter point -resize "10000%" output.png

Explanation:

  • Interpolation method "Integer" just picks a nearest value.
  • Filter 'point' is also necessary, but I do not know why.
like image 41
Unapiedra Avatar answered Nov 09 '22 03:11

Unapiedra


display -sample 400% worked for me.

"Change the image size simply by directly sampling the pixels original from the image. When magnifying, pixels are replicated in blocks. When minifying, pixels are sub-sampled (i.e., some rows and columns are skipped over)."

https://imagemagick.org/script/command-line-options.php#sample

like image 21
Wolfgang Brehm Avatar answered Nov 09 '22 02:11

Wolfgang Brehm