我有以下 SVG 文件:
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg">
<title>Kalender</title>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(-178.000000, -704.000000)" stroke="#0067C5">
<g transform="translate(139.000000, 20.000000)">
<g transform="translate(36.000000, 681.000000)">
<polyline points="7 5.66666667 4.33333333 5.66666667 4.33333333 19.6666667 19.6666667 19.6666667 19.6666667 5.66666667 17 5.66666667"></polyline>
<polygon points="7 4.33333333 9 4.33333333 9 7 7 7"></polygon>
<polygon points="15 4.33333333 17 4.33333333 17 7 15 7"></polygon>
<path d="M9,5 L15,5"></path>
<path d="M4.33333333,9 L19.6666667,9"></path>
</g>
</g>
</g>
</g>
它由一系列带有笔划的对象组成,我需要将其转换为路径。
在 Inkscape 的 GUI 版本中,我的问题的解决方案如下:
- 选择左侧工具栏上的“按节点编辑路径”工具(使用常规选择工具不起作用)
- 点击一个对象将其选中
- 然后转到“编辑 > 选择相同 > 笔触样式”(以选择具有相同笔触的所有其他对象)
- 然后转到“路径>描边到路径”
但我需要相同操作的 CLI 语法,以便为一系列 SVG 文件自动执行此过程。
我试过以下方法:
inkscape -f $1"-stroketopath/"$svgfile --verb="EditSelectAll" --verb="EditSelectSameStrokeStyle" --verb="StrokeToPath" --verb="FileSave" --verb="FileQuit"
这是行不通的。我怀疑它失败的原因与上述相同(“编辑 > 选择相同 > 描边样式”操作不适用于常规选择工具(在“编辑 > 全选”操作中使用)。
那么有谁知道如何将 --verb="EditSelectAll"
替换为使用“按节点编辑路径”工具的东西,然后选择文件中的一个或所有对象?
最佳答案
解决方案是遍历我所有的 SVG,并在类型为 path
的第一个元素上注入(inject)一个 id="inkscape"
属性,rect
、圆
、椭圆
、线
、折线
或多边形
。
然后我可以运行:
inkscape -f $svgfile --select="inkscape" --verb="EditSelectSameStrokeStyle" --verb="StrokeToPath" --verb="SelectionUnion" --verb="FileSave" --verb="FileQuit"
使用 --select
命令 ( details here )。
The --select command will cause objects that have the ID specified to be selected. This allows various verbs to act upon them. To remove all the selections use --verb=EditDeselect. The object IDs available are dependent on the document specified to load.
关于unix - 用于选择对象/路径的 Inkscape CLI 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48437956/