Skip to content

Instantly share code, notes, and snippets.

@archgrove
Created January 15, 2014 14:47
Show Gist options
  • Save archgrove/8437529 to your computer and use it in GitHub Desktop.
Save archgrove/8437529 to your computer and use it in GitHub Desktop.
# resizeIcons.sh # Creates new sizes from a source PNG in the iOS icon sizes
#!/bin/sh
# resizeIcons.sh
# Creates new sizes from a source PNG in the iOS icon sizes
# adamw@archgrove.co.uk
# Depends: sips (OS X scriptable image processing)
function resize {
currentImage=$1
newImage=$2
sizeX=$3
sizeY=$4
cp $currentImage $newImage
echo "Resizing $currentImage to $newImage at size $sizeX by $sizeY"
sips -z $sizeX $sizeY $newImage > /dev/null 2>&1
}
if [ -z $1 ]; then
echo "Usage: $0 image.png"
else
source=$1
base=${source%.*}
ext="${source##*.}"
if [ "png" != $ext ]; then
echo "Image must have a PNG extension"
else
resize $source $base-120.png 120 120
resize $source $base-80.png 80 80
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment