Skip to content

Instantly share code, notes, and snippets.

@sharoonthomas
Last active September 15, 2015 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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 icon-60@3x.png
# iOS 7.0+
# iPhone / iPod Touch
createIconImage 60 icon-60.png
createIconImage 120 icon-60@2x.png
# ipad
createIconImage 76 icon-76.png
createIconImage 152 icon-76@2x.png
# iOS 6.1
# Spotlight iCon
createIconImage 40 icon-40.png
createIconImage 80 icon-40@2x.png
# iPhone / iPod Touch
createIconImage 57 icon-57.png
createIconImage 114 icon-57@2x.png
# iPad
createIconImage 72 icon-72.png
createIconImage 144 icon-72@2x.png
# iPhone Spotlight and Settings Icon
createIconImage 29 icon-29.png
createIconImage 58 icon-29@2x.png
# iPad Spotlight and Settings Icon
createIconImage 50 icon-50.png
createIconImage 100 icon-50@2x.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment