Convert SVG to transparent PNG with antialiasing, using ImageMagick

后端 未结 8 899
耶瑟儿~
耶瑟儿~ 2020-12-07 13:06

I want to convert SVG images to PNG files with transparent background and anti-aliased edges (using semi-transparent pixels). Unfortunately I can\'t get ImageMagick to do th

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 13:56

    Inkscape will do this:

    inkscape \
        --export-png=out.png --export-dpi=200 \
        --export-background-opacity=0 --without-gui in.svg
    

    Update

    The terminology has changed: all the export params suppress gui, and the output parameter is now simply based on the file type. For example, a type of png will cause a file in /path/to/picture.svg to be exported as /path/to/picture.png (caution: this overwrites output).

    inkscape \
        --export-type=png --export-dpi=200 \
        --export-background-opacity=0 picture.svg
    

    Note cited wiki has quotes on --export-type=png, which is incorrect.

    Also if don't have Inkscape command line, MacOS can access via bash directly:

    /Applications/Inkscape.app/Contents/MacOS/inkscape
    

提交回复
热议问题