Is there any commandline tool that can remove transforms from an SVG file (or rather apply the transforms), translating all coordinates to stay in place?
This is one of the thing that none of the most well-known SVG cleaning tools (svgo, svgcleaner, etc) handles, as far as I understand.
In other words, I would like to go from something like this:
<g
transform="matrix(0.9,0,0,0.99,650,280)"
>
<path
d="M591,1037 L589,1044 ...
>
</g>
to something like this
<g>
<path
d="M204,503 L321,403 ...
>
</g>
...or from something like this:
<path
transform="matrix(0.9,0,0,0.99,650,280)"
d="M591,1037 L589,1044 ...
>
to something like this
<path
d="M204,503 L321,403 ...
>
Links
For reference, there is an old, unmaintained Inkscape extension that does this: Apply Transforms)
Stack Overflow question, with tips on how to do this in Inkscape (through the GUI), including a note that this used to be possible with svgo: Removing transforms in SVG files
Open ticket at the svgo repo: Please add the option to flatten transforms #624
SVGO works fine for your example. I tested on 3.2.0.
npm i -g svgo
andsvgo in1.svg in2.svg -o out1.svg out2.svg
:in1.svg
in2.svg
out1.svg
=out2.svg
Observe that all
transform
s are removed (applied) and things stay in place. I don't know why that issue is still open, possibly it's because of edge cases, but removing transforms is enabled by default.Keep an eye on the recent pull requests, and update when there are new releases. There are some small bugs that will be fixed soon. Shapes will be supported but the question talks about paths.