Created
June 5, 2013 17:41
-
-
Save suwa320/5715736 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
| ICONS=( | |
| "Icon.png 57x57" | |
| "Icon@2x.png 114x114" | |
| "Icon-72.png 72x72" | |
| "Icon-72@2x.png 144x144" | |
| "Icon-Small.png 29x29" | |
| "Icon-Small@2x.png 58x58" | |
| "Icon-Small-50.png 50x50" | |
| "Icon-Small-50@2x.png 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