Sometimes I use icons from The Noun Project in layouts, documents or presentations. You can only download the icons in SVG format which is great because you can scale them as you like. However you need to convert them into another format before you can use them. Since even Photoshop is not able to open SVG files I always need to start Illustrator to convert them into PNG. I thought there must be a better solution.
brew install librsvg
At least since version 2.36.1 the name of the command is now
rsvg. I update the article to reflect this change. However, if you want to continue to use
rsvg(since it is shorter) you can create a symlink:
ln -s /usr/local/bin/rsvg-convert /usr/local/bin/rsvg
You know have to use the parameter
-oto specify the output PNG file. I updated the article to reflect that. Thanks Tim.
Now you can use the rsvg command line tool. For example, to convert noun_project_836.svg into a PNG file with 200px width you can do:
rsvg-convert -w 200 noun_project_836.svg -o noun_project_836.png
You can also provide the required height of the output image:
rsvg-convert -h 200 noun_project_836.svg -o noun_project_836.png
As long as you only provide width or height the other dimension will be scaled accordingly. If you provide both width and height the resulting image will have exactly the given dimensions:
rsvg-convert -w 200 -h 200 noun_project_836.svg -o noun_project_836.png
That’s it. Super simple SVG to PNG conversion.