Skip to content

Instantly share code, notes, and snippets.

@sharoonthomas
Last active September 15, 2015 21:51
Show Gist options
  • Save sharoonthomas/71464e7ce344a7fddf79 to your computer and use it in GitHub Desktop.
Save sharoonthomas/71464e7ce344a7fddf79 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This script assumes that ImageMagick is installed and the convert command is accessible via the $PATH variable
# Ensure that one argument has been passed in.
if [ ! "$#" -eq 1 ]
then
echo -e "This script requires one argument.\\ne.g. iOS_icon_maker.sh app_icon.png"
exit 1
fi
# Assign the argument to the path variable so it is easier to follow throughout the script.
path=$1
# Ensure that the path points to a valid file.
if [ ! -f "$path" ]
then
echo "Path must point to a valid file."
exit 1
fi
# This function takes in the dimension of the icon (it assumes the icon is a square) and the name of the file to save the icon to.
function createIconImage()
{
iconDimension=$1
iconName=$2
convert "$path" -resize ${iconDimension}x${iconDimension}^ -gravity center -extent ${iconDimension}x${iconDimension} $iconName
}
# Create all the suggested icons for both the iPhone and iPad platforms to ensure the best appearance.
# iOS 8.0+
# iPhone 6 Plus
createIconImage 180 [email protected]
# iOS 7.0+
# iPhone / iPod Touch
createIconImage 60 icon-60.png
createIconImage 120 [email protected]
# ipad
createIconImage 76 icon-76.png
createIconImage 152 [email protected]
# iOS 6.1
# Spotlight iCon
createIconImage 40 icon-40.png
createIconImage 80 [email protected]
# iPhone / iPod Touch
createIconImage 57 icon-57.png
createIconImage 114 [email protected]
# iPad
createIconImage 72 icon-72.png
createIconImage 144 [email protected]
# iPhone Spotlight and Settings Icon
createIconImage 29 icon-29.png
createIconImage 58 [email protected]
# iPad Spotlight and Settings Icon
createIconImage 50 icon-50.png
createIconImage 100 [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment