-
-
Save antranapp/46ca69d255b54e1e72bc to your computer and use it in GitHub Desktop.
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/sh | |
function print_example() { | |
echo "Example" | |
echo " icons ios ~/AppIcon.png ~/Icons/" | |
} | |
function print_usage() { | |
echo "Usage" | |
echo " icons <ios|watch|all> in-file.png (out-dir)" | |
} | |
function command_exists() { | |
if type "$1" >/dev/null 2>&1; then | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
if command_exists "convert" == 0 ; then | |
echo "ImageMagick tool 'convert' not found" | |
exit 1 | |
fi | |
if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then | |
print_usage | |
exit 0 | |
fi | |
PLATFORM="$1" | |
FILE="$2" | |
if [ -z "$PLATFORM" ] || [ -z "$FILE" ] ; then | |
echo "Error: missing arguments" | |
echo "" | |
print_usage | |
echo "" | |
print_example | |
exit 1 | |
fi | |
DIR="$3" | |
if [ -z "$DIR" ] ; then | |
DIR=$(dirname $FILE) | |
fi | |
# Create directory if needed | |
mkdir -p "$DIR" | |
if [ "$PLATFORM" == "all" ] ; then | |
PLATFORM="ios watch" | |
fi | |
if [[ "$PLATFORM" == *"ios"* ]] ; then # iOS | |
convert -resize '120x120' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '180x180' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '29x29' "${FILE}" "${DIR}"/iPadSettings.png | |
convert -resize '58x58' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '58x58' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '87x87' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '40x40' "${FILE}" "${DIR}"/iPadSpotlight.png | |
convert -resize '80x80' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '80x80' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '120x120' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '76x76' "${FILE}" "${DIR}"/iPad.png | |
convert -resize '152x152' "${FILE}" "${DIR}"/[email protected] | |
fi | |
if [[ "$PLATFORM" == *"watch"* ]] ; then # Apple Watch | |
convert -resize '48x48' "${FILE}" "${DIR}"/Watch38mmNotificationCenter.png | |
convert -resize '55x55' "${FILE}" "${DIR}"/Watch42mmNotificationCenter.png | |
convert -resize '58x58' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '87x87' "${FILE}" "${DIR}"/[email protected] | |
convert -resize '80x80' "${FILE}" "${DIR}"/WatchAllHomeScreen.png | |
convert -resize '88x88' "${FILE}" "${DIR}"/WatchLongLook.png | |
convert -resize '172x172' "${FILE}" "${DIR}"/Watch38MMShortLook.png | |
convert -resize '196x196' "${FILE}" "${DIR}"/Watch42MMShortLook.png | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment