Search code examples
imagemagickimagemagick-convert

ImageMagick: Zoom an image by integral zoom factor without any smoothing?


I have a 256×256 PNG image in a.png that just consists of black and white pixels.

What I want is just to zoom it by a factor of 4, so that each pixel becomes a 4×4 block of the same color. So what I did is:

> convert a.png -geometry 1024x1024 a4.png

The problem is that the resulting image a4.png is blurred and is no more 2-colored black-and-white.

What does not work:

  • With -colors 2 I am getting an output with only 2 colors, but they are grey-ish, not black + white. And the image looks dithered even with -dither none.
  • -dither none has no effect.
  • -quantize-colorspace has no effect.
  • -solarize 128 has no effect either.
  • -depth 1 does not work (shreds the image).

Thanks in advance for any hints.


Solution

  • Try:

    convert input.png -scale 1024x1024 result.png