Quickly convert SVG graphics into PNG images

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.

Once again help is provided by the Terminal. First you need LibRsvg, which is easy to install if you have Mac OS X and Homebrew already installed:

brew install librsvg
Update 29th of July:
At least since version 2.36.1 the name of the command is now rsvg-convert instead of 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
Update 9th of November:
You know have to use the parameter -o to 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.

4 thoughts on “Quickly convert SVG graphics into PNG images

  1. It look like the command line tool got renamed to rsvg-convert (I have librsvg-2.36.1 installed. Thanks for the post—this works beautifully.

  2. I just tried

    rsvg-convert -w 400 VGB.svg VGB.png

    and got

    Multiple SVG files are only allowed for PDF and PS output.

    this seems to be solved by adding the ‘-o’ flag before the output file like so:

    rsvg-convert -w 400 VGB.svg -o VGB.png