An SVG has these properties, that determine its size:
width="146.91299pt"
height="78.079002pt"
viewBox="0 0 146.913 78.079"
I would like to scale a given SVG to a with of 400pt
by command line without breaking the aspect ratio. This means, the three values above have to be changed correctly and all points in the following svg code. I don't want to change only the canvas size, but the whole svg image size. And I don't want to do it with a GUI/by hand, but I want to do it with CLI.
How can I automatically scale an SVG by command line to a given width?
Reason: The preview of Wikipedia looks bad if the image is too small. See this image as an example.
How I would do this task with Inkscape-GUI
- Shift+Ctrl+M (Transform)
- Scale (check "scale proportionally")
- Enter width
- Shift+Ctrl+D (Document properties)
- Fit page to selection
Now I want a automatic CLI-way to do this.
By the way, inkscape simply applied
<g transform="matrix(1.6838397,0,0,1.6838397,-3.3543029,-3.3542794)"
id="surface0">
to the whole image.
Best Answer
rsvg-convert
from thelibrsvg2-bin
package can resize svg's.See this answer for full instructions.