Programmatically convert SVG shapes to paths (lineto, moveto)

半城伤御伤魂 提交于 2019-12-04 03:57:18
Paul Sweatte

Inkscape has a command-line interface. Use the Inkscape man page along with the verb source for reference:

The ObjectToPath verb converts an object to a path:

inkscape filename.svg --select=myobject --verb=ObjectToPath --export-plain-svg=filename_to_path.svg

The export-text-to-path argument converts text nodes to paths:

inkscape filename.svg --export-eps=filename.eps --export-text-to-path

These are related questions on how to run InkScape from Perl, Ruby, PHP or Python:

This is what finally worked for me:

inkscape -f filename.svg --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileQuit

It takes about 9 seconds to run and briefly opens the inkscape gui, which becomes the active application, so it's not ideal, but it's the only answer I could find that actually works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!