0

I have a large SVG with several groups. Each group has a transform. I want to recalculate / flatten the transforms while preserving the groups.

<g id="a" transform="matrix(2 0 0 2 -69.46 -152.7)">
   <path d="m64.3 645.3h165.9c3...
   <path d="m123 567.4h963...
</g>
<g id="b" transform="matrix(3 0 0 3 -69.46 -152.7)">
   <path d="m64.3 645.3h165.9c3...
   <path d="m123 567.4h963...
</g>
...

All the solutions I've found so far involve using Inkscape and then ungrouping. I do not want to ungroup them - I have lots of groups and it is important that they stay grouped.

  • SVGcleaner does not apply transforms to paths within groups.
  • svgo has an outstanding bug for this
  • Inkscape requires ungrouping.
Terence Eden
  • 14,034
  • 3
  • 48
  • 89
  • 1
    Have you tried this tool? https://lean-svg.netlify.com/ It can flatten transforms. But it may not work properly on *every* SVG. – Paul LeBeau Jul 04 '19 at 13:02
  • Ah! That does partly work! It flattens the paths. But, sadly, it removes lots of other information like text positioning and hyperlinks. I'll have a play with the settings. Thank you for your help. – Terence Eden Jul 04 '19 at 14:27
  • Duplicate of https://stackoverflow.com/questions/13329125/removing-transforms-in-svg-files – Moini Jul 04 '19 at 18:33
  • @moini I do not think it is a duplicate. The answers there rely on Inkscape which, as I mention, doesn't meet the needs of this specific question. – Terence Eden Jul 04 '19 at 20:28
  • Well, you tagged it Inkscape... And it can do what you need. – Moini Jul 05 '19 at 12:03

0 Answers0