Gimp svg to png script

Posted by Jason Hardin on August 23, 2012

Been working on icons for Moodlerooms mockups using Balsamiq and was pointed to by a response to a comment I made. Rather than reading the actual documentation after downloading the icons I looked for a way to convert the svg file to png files. I then found, which now seems defunct. While for gimp 2.2 I figured out the changes I needed to make, mostly to the -b option to be –batch= and the –batch-interpreter=plug-in-script-fu-eval. I never did get the shell script to work but ended up just using the shell for command that I fixed. It looks like:

 for f in *.svg; do gimp -i --batch="( svg-to-raster "$f" "${f%.svg}.png" 300 128 128)" --batch='(gimp-quit 0)'; done

Before that I ran:

 for f in *.svg; do mv $f icon_$f; done

This renames all the files to have the prefix icon_ which is needed by Balsamiq for icons that are located in the assets directory.