#!/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 hash xmllint; then # Should be pre-installed on OS X. xmllint $file -o $file --pretty 1 fi # 2. Convert SVG files to PNG. if hash rsvg-convert; then # Can be installed with Homebrew. (Installation is slow, but conversion is fast.) # brew install librsvg rsvg-convert $file -o $png elif hash svgexport; then # Can be installed with NPM. (Installation is fast, but conversion is slow.) # npm install -g svgexport svgexport $file $png fi # 3. Minify PNG files. if hash imageoptim; then # Can be installed with NPM. (Note: You must already have the GUI application installed.) # npm install -g imageoptim-cli echo $png | imageoptim fi fi done