Search code examples
svginkscape

Get rid of viewBox transform in an Inkscape generated SVG


I have a question similar to this one. That is, I have an SVG file created by Inkscape, and there is additional transforms on the paths I want to get rid off.

Now instead of having a transform matrix, there is a different type of transform. For example, the header goes like this:

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.0"
   width="32"
   height="32"
   viewBox="0 0 16.146082 22.465583"
   id="svg2"
   xml:space="preserve"
   ...
</svg>

Apparently this mess is interpreted as some sort of translation and scaling. If I remove the viewBox attribute, the paths shrink and appear a bit to the left. So if I just copy the path definitions, my image is not 32 x 32 but smaller.

How can I flatten the transform somehow introduced by viewBox so it is integrated into the explicit path coordinates?


Solution

  • I created a second empty document, and used copy and then paste-in-place. The viewBox is not part of the new document, but you have transformation which you must get rid of using the method described in the linked question (remove the g group node, then re-position using absolute coordinates.).