Last active
August 29, 2015 14:18
-
-
Save nonstriater/16fbcb07eae8eb310b5f to your computer and use it in GitHub Desktop.
生成app icon的各个尺寸
This file contains 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 | |
######################### | |
# usage: iosicon.sh 1024-icon.png | |
######################### | |
function print_usage(){ | |
echo "################################" | |
echo "usage: iosicon.sh <1024-icon.png>" | |
echo "################################" | |
} | |
#check arg | |
if [[ -z "$1" && $# -ne 1 ]]; then | |
print_usage | |
exit 1 | |
fi | |
# prepare | |
ROOT_DIR=$(pwd) | |
#check file exist | |
SOURCE_FILE="${ROOT_DIR}/$1" | |
if [[ ! -e ${SOURCE_FILE} ]]; then | |
echo "source file not exist!" | |
exit 2 | |
fi | |
DEST_DIR="${ROOT_DIR}/ios-icon" | |
mkdir -p "${DEST_DIR}" | |
ICON_ARRAY_NAME=("Icon-29.png" "[email protected]" "Icon-40.png" "[email protected]" "Icon.png" "[email protected]" "[email protected]" "[email protected]") | |
ICON_ARRAY_SIZE=("29" "58" "40" "80" "57" "114" "120" "180") | |
#sips starting | |
cp "${SOURCE_FILE}" "${DEST_DIR}" | |
for ((i=0; i<${#ICON_ARRAY_SIZE[@]} ;i++)); do | |
size=${ICON_ARRAY_SIZE[i]} | |
sips -Z ${size} "${SOURCE_FILE}" --out "${DEST_DIR}/${ICON_ARRAY_NAME[i]}" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment