Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/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 ]
echo -e "This script requires one argument.\\ne.g. app_icon.png"
exit 1
# Assign the argument to the path variable so it is easier to follow throughout the script.
# Ensure that the path points to a valid file.
if [ ! -f "$path" ]
echo "Path must point to a valid file."
exit 1
# 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()
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
You can’t perform that action at this time.