Skip to content

Instantly share code, notes, and snippets.

@vikynandha-zz
Last active September 17, 2015 10:51
Show Gist options
  • Save vikynandha-zz/52ee9154d35e5383a84a to your computer and use it in GitHub Desktop.
Save vikynandha-zz/52ee9154d35e5383a84a to your computer and use it in GitHub Desktop.
Shell script to export SVG files in bulk to PNG
### TODO: Support command-line options (width, bg color, etc)
if [ $# -eq 0 ]; then
echo 'No arguments passed.'
echo "Usage: svgexport <SVG files to export>"
echo "Say \"svgexport .\" to export all SVGs in current directory"
exit 1
else
pattern=$*
fi
for f in $(ls $pattern)
do
if [[ $f == *.svg ]]; then
basename=$(basename $f .svg)
dest="$(dirname $f)/PNG/"
mkdir -p $dest
inkscape -z -C -e "$dest/$basename.png" -D -b 'ffffff' $f
else
echo "Skipping $f - not an SVG file."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment