: In Inkscape, resize both the document and its content at the same time I've been struggling to do something that would seem pretty basic: In Inkscape, how can I resize the document and its
I've been struggling to do something that would seem pretty basic:
In Inkscape, how can I resize the document and its content (i.e. drawings) at the same time?
A little bit of context: I want to resize a fairly large number of SVG documents from The Noun Project (they are typically 100x100px docs) without having to explicitly resize the actual drawings.
N.B: If there's a command line solution, I can work with that too!
More posts by @Marchetta832
3 Comments
Sorted by latest first Latest Oldest Best
While there's a few ways to do it - as noted here - one way that can work really well is to use a viewBox. You simply modify the contents of the SVG tag like so:
<svg
width="1280"
height="800"
viewBox="0 0 1280 800">
<!-- More markup... --!>
</svg>
What viewBox does is it defines an internal coordinate system for the document. You can then easily scale the document simply by modifying the width and height attributes as necessary.
Note that there are some drawbacks, though. For one thing, there's only certain contexts this works in, specificially if you're somehow directly including the SVG document on your markup page. Using an <img> tag with this may or may not yield unexpected results. You'll have to do some of your own research to figure out how best to do this.
You haven't mentioned what OS you're running. I'm using Ubuntu, and I've been able to use librsvg2 successfully.
If you have access to Ubuntu, here's what you can do. First, install librsvg2:
sudo apt-get install librsvg2-bin
Then, cd to the directory that has your SVGs (make sure it only has SVGs!) and use a command like the following:
for i in *; do rsvg-convert $i -w 160 -h 160 -f svg -o `echo $i | sed -e 's/svg$/new.svg/'`; done
This will create a new batch of SVGs with dimensions 200px by 200px, and saved as "original-file-name.new.svg"
Calculating dimensions is somewhat confusing. For converting SVG to SVG, you need to do a little bit of math. The "height" and "width" options in rsvg-convert use pt, not px, in such cases, so use 80 if you want 100px, 120 if you want 150px, and so on.
You can also use rsvg-convert to output PNGs. It is much better at rasterizing the file than ImageMagick, at least in my experience. Notice that you need to change -f to png, you need to change the output save pattern from 's/svg$/new.svg/' to 's/svg$/png/', and you enter the width and height that you want as the pixel values.
for i in *; do rsvg-convert $i -w 200 -h 200 -f png -o `echo $i | sed -e 's/svg$/png/'`; done
There is currently no native way to do that in Inkscape. The only way is to resize content and document separately.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.