【问题标题】:Programmatically convert SVG shapes to paths (lineto, moveto)以编程方式将 SVG 形状转换为路径(lineto、moveto)
【发布时间】:2013-02-18 15:57:03
【问题描述】:

我有一个来自 Inkscape、Illustrator 或任何其他应用程序的 SVG 文件。我想将形状转换为linetomovetocurveto 格式。

我想要的是这样的:

./Appname svgfile outfilewithpath

我会将 SVG 文件作为参数,然后我的应用程序会将对象转换为相应的路径。

【问题讨论】:

  • 为了明确一点,您想将rectcircleellipsepolygon 等元素转换为路径?
  • 我开始了解 Inkscape 并发现它可以完成这项工作,但我想要的是我已经从任何软件中制作了 svg 并希望将对象转换为路径。即移至行至。接受 Qt、Perl、Python、C、C++ 任何解决方案。

标签: svg automation coordinates shapes save-as


【解决方案1】:

Inkscape 有一个命令行界面。使用Inkscape man pageverb source 供参考:

ObjectToPath 动词将对象转换为路径:

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

export-text-to-path 参数将文本节点转换为路径:

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

这些是关于如何从 Perl、Ruby、PHP 或 Python 运行 InkScape 的相关问题:

【讨论】:

  • Inkscape 本身可以做这些事情,我也非常了解inkscape 命令行。我正在寻找其他解决方案,也许是 Python 或 perl。例如。 Python/PerlApp svgfile outfilewithcoordinate.txt。我知道 svg 是 xml 文件,可以用 xml 库解析。
【解决方案2】:

这最终对我有用:

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

运行大约需要 9 秒,并短暂打开 inkscape gui,它成为活动应用程序,因此并不理想,但这是我能找到的唯一有效的答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 2012-01-14
    • 2015-03-06
    • 2019-04-28
    • 2013-05-29
    • 1970-01-01
    • 2013-04-21
    相关资源
    最近更新 更多