Max Glenister

Software & Servers • 2 min read Plain text

Converting SVG to PNG online and in your terminal

This post is mostly for my own benefit on the rare occasion that I have to convert SVG files to PNG.

I always spend a large amount of time looking for an online SVG to PNG converter or a terminal one-liner to do this.

SVG icon resources:

Online services to convert SVG to PNG that aren’t totally rubbish:

Convert SVG to PNG using your terminal (Mac, Linux):

First install librsvg using brew:

$ brew update && brew upgrade
$ brew install librsvg
$ ln -s /usr/local/bin/rsvg-convert /usr/local/bin/rsvg

Then, you can either using rsvg directly, or make a function like the following:

# svg2png [file] [width] [height]
function svg2png {
    file=$1
    file_name="${file%.*}"
    file_ext="${file##*.}"
    shift
    width=${1:-"128"}
    height=${2:-"128"}

    if [ "${file_ext}" != "svg" ]; then
        printf "\n${file} is not an svg!\n"
    else
        rsvg -w $width -h $height "${file}" -o "${file_name}.png"
    fi
}

If you found this useful let me know, I for one am glad that I’ve got this information in one place now.

  • UX & Design · shares #guide
    Launching Sketch Toolbox from inside Sketch

    I’ve been making use of Sketch a lot lately. One of the coolest features of Sketch is it’s plugin support. I’m using a tool called Sketch Toolbox to manage plugins in Sketch – this functions a lot like Package Control for Sublime Text, but it’s a stand-alone application.

    July 2015 • 2 min read
  • UX & Design · shares #software
    Creating 'Material Design' shadows in Photoshop

    Somebody over on Designer News asked how to re-create the various z-height shadow effects from Google’s Material Design in Photoshop.

    January 2015 • 2 min read
  • UX & Design · shares #design
    Making GIMP feel less like punishment

    GIMP has always had an interface problem. I’m not blaming the GIMP team (they’ve built something powerful on a shoestring). They’ve been clear they’re not interested in copying Photoshop wholesale; their FAQ argues that designing around actual user research beats imitating someone else’s interface decisions. Fair enough in principle, but coming from years as a Photoshop user, that design still feels hostile to me. I’m just one user story out of many they’ve had to design for, but it still expects me to learn its own way of doing things rather than offering a config closer to what I’m used to out of the box.

    June 2026 • 2 min read

Discussion

  • R

    Also ksvgtopng in Ubuntu package kde-runtime

  • S

    thank you. Totally awesome…..the grump icon that is :-)

  • N

    Don’t follow the instructions for the librsvg install - I did it without thinking about the commands and what happened was it upgraded a bunch of my tools! Now I have to go through a few hours of testing and upgrading other tools just to get my development environment back up. And to top it off, brew was not able to install the lbrsvg tool due to dependencies that it could not install.Yup, it’s my fault I should not have blindly followed the above directions, hopefully this post will keep someone else from making the same mistake.

  • I suppose you should say “Don’t blindly follow the instructions” then – for most people updating and upgrading brew is a good first step, and if it’s not they would know otherwise.

Join the conversation

Reply from your own site with a Webmention (how?).

Webmentions last fetched 17 November 2026, 13:05