Search code examples
imagemagickimagemagick-convert

Export .svg to .png without (any) antialiasing (`+antialias` doesn't work)


I'm trying to export a svg file to an icon sized .png. The problem is that I can't seem to be able to force ImageMagick to not to use antialiasing.

It seems to me that +antialias only turns off between colors aliasing but doesn't prevent to-alpha-channel aliasing.

I've tried:

  • convert +antialias -background none plug.svg -resize 32x32 plug.png
  • convert +antialias -background none -size 32x32 plug.svg -resize 32x32 plug.png
  • Putting the +antialias keyword anywhere in the clause...

And all of them produce:

enter image description here


Imagemagics version: Version: ImageMagick 6.7.7-10 2017-02-22


Solution

  • If you want to force ImageMagick to use 1-bit alpha channel, try using PNG-8 and set a better filtering algorithm such as Lanczos:

    -filter Lanczos -resize 64x png8:result64px.png
    

    This is an enlarged result with a 1-bit alpha channel:

    Magnified result