Export .svg to .png without (any) antialiasing (`+

2019-07-24 03:40发布

问题:

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:


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

回答1:

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: