I have a logo image in SVG format and I am wondering if theres a way to generate multiple different sized png files.
Eg, I set 20 different width and height and it gener
If you haven't already, install imagemagick
. On OSX, that requires rsvg
support specifically:
brew install imagemagick --with-librsvg
You also need inkscape, otherwise you may find that your images come out all black (except for transparent areas).
brew install homebrew/gui/inkscape
Then, you should be able to convert as follows:
convert -density 1536 -background none -resize 100x100 input.svg output-100.png
The 1536
is a workaround for something I'm not able to find good answers to. In my experiments, omitting the -density
argument creates images that are terribly small. Converting an image to -size 100x100
at -density 1024
gives me an output image of 96x96
, so what I'm doing instead is overshooting on the density and resizing down to the target size.
TL;DR use a density that is 1500 times larger than your target size, and go from there.
There are many ways to bulk-run that command. Here is one in the shell:
for s in 10 100 200 ; do convert -density 1536 -background none -resize ${s}x${s} input.svg output-${s}.png ; done