Created
November 28, 2013 11:10
-
-
Save aaronsnoswell/7690312 to your computer and use it in GitHub Desktop.
Convert SVGs to PNGs recursively
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
#!/bin/sh | |
# Convert .svg files to .png - works on a single file or | |
# recursively on the given directory. | |
# Requries ImageMagick's `convert` function | |
# Author: Aaaron Snoswell | |
density=${2-72} | |
function convertsvg () { | |
echo "Converting '$2' -> '${2%.*}.png'" | |
convert -density $1 "$2" "${2%.*}".png | |
} | |
export -f convertsvg | |
if [ -d "$1" ] ; then | |
find $1 -iname "*.svg" -exec bash -c "convertsvg $density \"{}\"" \; | |
else | |
convertsvg $density $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment