Search code examples
svgimagemagickinkscape

how to export svg to png on the command line without antialiasing


I need to do some batch processing of svg files. SVG elements are all either black or white and I need bitmap images that are monochrome (black/white, no grayscale).

From within the inkscape gui I can just select this as an option.

enter image description here

However, I don't see any inkscape cli options related to antialiasing

Same for librsvg, (rsvg-convert) no command line options in the manual related to anti-aliasing.

Second thought was to just export to a png image and then use ImageMagick to threshhold the image. However, on my system

Mac OSX catalina (latest)
brew install imagemagick -> 7.0.10-23

when I run the following, i get an error:

>>> convert test.im.png -channel RGB -threshhold 50% test.im.t.png
convert: unrecognized option `-threshhold' @ error/convert.c/ConvertImageCommand/3112.

looking for a little help on how to get from a black and white svg to a black and white png on the command line for batch processing given these problems.


Solution

  • On IM 7, use magick, not convert. So try

    magick +antialias image.svg -channel RGB result.png
    

    or

    magick image.svg -channel RGB -threshold 50% result.png
    

    If one of these works, then you can process a whole folder of files using magick mogrify. See https://imagemagick.org/Usage/basics/#mogrify