I have the following SVG-file:
<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>
Which consists of a series of objects with strokes which I need to convert to paths.
In the GUI version of Inkscape the solution to my problem is the following steps:
But I need the CLI syntax for the same operation in order to automate this process for a series of SVG files.
I've tried the following:
inkscape -f $1"-stroketopath/"$svgfile --verb="EditSelectAll" --verb="EditSelectSameStrokeStyle" --verb="StrokeToPath" --verb="FileSave" --verb="FileQuit"
Which doesn't work. And I suspect it fails for the same reason as noted above (that the "Edit > Select Same > Stroke style" operation doesn't work with the regular selection tool (which is utilized in the "Edit > Select all" operation).
So does anyone know how to replace --verb="EditSelectAll" with something that uses the "Edit paths by nodes" tool and then select one or all of the objects in the file?
The solution to this was to run through all of my SVGs and inject an id="inkscape" attribute on the first element of type path, rect, circle, ellipse, line, polyline or polygon.
Then I could run:
inkscape -f $svgfile --select="inkscape" --verb="EditSelectSameStrokeStyle" --verb="StrokeToPath" --verb="SelectionUnion" --verb="FileSave" --verb="FileQuit"
Using the --select command (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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With