Skip to content

Instantly share code, notes, and snippets.

@slopjong
Created June 1, 2014 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slopjong/4f0f0160862a12953efc to your computer and use it in GitHub Desktop.
Save slopjong/4f0f0160862a12953efc to your computer and use it in GitHub Desktop.
Converts a single SVG or a set of SVGs to PNG
#!/bin/bash
function convert()
{
file="$1"
# remove the svg file extension and append .png
destination="${file%.svg}.png"
# -z is for launching inkscape without the gui
inkscape -z --export-png=$destination --export-area-drawing $file
}
export -f convert
if [ ! -z "$1" ]
then
convert $PWD/$1
else
find img -name "*.svg" -exec bash -c "convert {}" \;
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment