Mass Converting .svg to .png on macOS

When playing around with Royal TSX I needed to mass convert the VMware Clarity .svg files to .png files that I could use as icons in Royal TSX.

After trying a series of different approaches, I ended up with using rsvg-convert from libRSVG. In order to get rsvg-convert installed on my MacBook, I turned to HomeBrew.

HomeBrew, which calls itself The missing package manager for macOS is in my opinion essential for any macOS user. If you are missing a command or utility, chances are that HomeBrew has you covered.

Mass Converting:

Once you have HomeBrew installed, you’re pretty much ready to go by running the following command in Terminal:

brew install librsvg

This installs the libRSVG formulae, and all it’s dependencies, and makes rsvg-convert available.

Once libRSVG installed locally, you can mass-convert .svg files by running the following command in your terminal of choice.

for i in *; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done

This loops through every .svg file in the current directory, and creates .png versions of them, for usage elsewhere.

1 Comment

Leave a Reply