#!/bin/sh for file in $1*.svg; do if [[ $file != 'none'* ]]; then png=`echo $file | sed s/.svg/.png/` # 1. Clean up SVG file. if type xmllint &>/dev/null; then # Should be pre-installed on OS X. xmllint $file -o $file --pretty 1 fi # 2. Convert SVG files to PNG. if [ ! -f "$png" ]; then if type rsvg-convert &>/dev/null; then # Can be installed with Homebrew. (Installation is slow, but conversion is fast.) # brew install librsvg echo "rsvg-convert: converting $file" rsvg-convert $file -o $png elif type svgexport &>/dev/null; then # Can be installed with NPM. (Installation is fast, but conversion is slow.) # npm install -g svgexport echo "svgexport: converting $file" svgexport $file $png fi fi fi done