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.
width
,height
, andviewBox
values to something likewidth="100%" height="100%" viewBox="0 0 400 212.58569"
.sed
in @terdon's answer). One problem you may run into is that the values need may to be different with any other .svg files you want to do the same thing to.