Skip to content

Instantly share code, notes, and snippets.

@suwa320
Created June 5, 2013 17:41
Show Gist options
  • Save suwa320/5715736 to your computer and use it in GitHub Desktop.
Save suwa320/5715736 to your computer and use it in GitHub Desktop.
#!/bin/bash
ICONS=(
"Icon.png 57x57"
"[email protected] 114x114"
"Icon-72.png 72x72"
"[email protected] 144x144"
"Icon-Small.png 29x29"
"[email protected] 58x58"
"Icon-Small-50.png 50x50"
"[email protected] 100x100"
)
INPUT_FILE=$1
OUTPUT_DIR=$2
if [ ! -f $INPUT_FILE ]
then
echo "no such file : $INPUT_FILE"
exit 1
fi
if [ ! -d $OUTPUT_DIR ]
then
echo "no such directory : $OUTPUT_DIR"
exit 1
fi
INKSCAPE=`which inkscape`
if [ $? -ne 0 ]
then
if [ -d "/Applications/Inkscape.app" ]
then
INKSCAPE="/Applications/Inkscape.app/Contents/Resources/bin/inkscape"
else
echo "inkscape not found"
exit 1;
fi
fi
for ((i = 0; i < ${#ICONS[@]}; ++i))
do
OUTPUT_FILE=`echo ${ICONS[$i]} | cut -f 1 -d ' '`
WIDTH=`echo ${ICONS[$i]} | cut -f 2 -d ' ' | cut -f 1 -d x`
HEIGHT=`echo ${ICONS[$i]} | cut -f 2 -d ' ' | cut -f 2 -d x`
$INKSCAPE --export-png=$OUTPUT_DIR/$OUTPUT_FILE --export-area-page \
--export-width=$WIDTH --export-height=$HEIGHT $INPUT_FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment