Last active
September 17, 2015 10:51
-
-
Save vikynandha-zz/52ee9154d35e5383a84a to your computer and use it in GitHub Desktop.
Shell script to export SVG files in bulk to PNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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