使用inkscape命令行将svg转换为png失败

edd*_*cat 4 svg png inkscape

我觉得我必须做一些愚蠢的错事,但我无法让它发挥作用.这是我从cmd运行的命令:

inkscape.com "C:\path\ship.svg" -e --export-png="C:\Path\ship.png" --without-gui
Run Code Online (Sandbox Code Playgroud)

作为回报,我得到:

WARNING: File path "--export-png=C:\path\ship.png" includes directory that doesn't exist.

它确实存在.我错过了什么?

Mar*_*ski 14

只是 2021 年的更新:

inkscape \
    --export-width=128 \
    --export-type=png \
    --export-filename="C:\path\ship.png" \
    "C:\path\build.svg"
Run Code Online (Sandbox Code Playgroud)

或者如果你想要透明的 PNG,请添加--export-background-opacity=0

inkscape \
    --export-background-opacity=0 \
    --export-width=128 \
    --export-type=png \
    --export-filename="C:\path\ship.png" \
    "C:\path\build.svg"
Run Code Online (Sandbox Code Playgroud)


Gol*_*rol 9

-e--export-png是相同的参数,根据该文档.-e只是简短的版本.所以你应该使用其中一个,但不能两个都使用.

因为你有-e,程序认为这--export-png="C:\Path\ship.png"是png文件的路径.

改成:

inkscape.com "C:\path\ship.svg" -e "C:\Path\ship.png" --without-gui
Run Code Online (Sandbox Code Playgroud)

要么:

inkscape.com "C:\path\ship.svg" --export-png="C:\Path\ship.png" --without-gui
Run Code Online (Sandbox Code Playgroud)

  • 在我的 Mac 上,它可以工作。也许您需要指定完整路径,在我的例子中为 `/Applications/Inkscape.app/Contents/MacOS/inkscape` 您也可以将其添加到路径中,或者创建到应用程序的符号链接 `ln -s /Applications/ Inkscape.app/Contents/MacOS/inkscape /usr/local/bin/inkscape` (2认同)