Skip to content

Instantly share code, notes, and snippets.

@nonstriater
Last active August 29, 2015 14:18
Show Gist options
  • Save nonstriater/16fbcb07eae8eb310b5f to your computer and use it in GitHub Desktop.
Save nonstriater/16fbcb07eae8eb310b5f to your computer and use it in GitHub Desktop.

Revisions

  1. nonstriater renamed this gist Apr 9, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. nonstriater renamed this gist Apr 9, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. nonstriater created this gist Apr 9, 2015.
    44 changes: 44 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #! /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