#! /bin/sh INKSCAPE="inkscape" PNGCRUSH="pngcrush" PNGCRUSH_ARGS="-q" SVG_INPUT="glance-icon.svg" PNG_OUTPUT="glance-icon.png" DPI="162" # works out to a 128x128 px PNG OUTDIR="../pyglance/glance/" command_unavailable() { command -v "$1" > /dev/null if [ $? = 0 ] ; then return 1 fi return 0 } if command_unavailable "$INKSCAPE" ; then echo "FATAL ERROR: \"$INKSCAPE\" is unavailable." exit 1 fi $INKSCAPE "$SVG_INPUT" --export-png="$PNG_OUTPUT" --without-gui --export-dpi="$DPI" | egrep -v '^(DPI|Background RRGGBBAA|Bitmap saved as): ' if [ ! $? ]; then echo "FATAL ERROR: \"$INKSCAPE\" failed." exit 1 fi if command_unavailable "$PNGCRUSH" ; then echo "Notice: \"$PNGCRUSH\" is not available; the resulting icon will be a bit (~15%) larger than necessary" else mv "$PNG_OUTPUT" "$PNG_OUTPUT.tmp" "$PNGCRUSH" "$PNGCRUSH_ARGS" "$PNG_OUTPUT.tmp" "$PNG_OUTPUT" if [ ! $? ]; then echo "Notice: \"$PNGCRUSH\" failed. The resulting icon will be a bit (~15%) larger than necessary" cp "$PNG_OUTPUT.tmp" "$PNG_OUTPUT" fi rm "$PNG_OUTPUT.tmp" fi cp "$PNG_OUTPUT" "$OUTDIR"