#!/bin/bash
FOLDER="$@"
if [ -n "$FOLDER" ] && [ -d "$FOLDER" ] && [ -f "$FOLDER/favicon.png" ]; then
	#FOLDER="$(cd "$(dirname "$IMAGEPATH")" && readlink -f "$(pwd)")"
	convert "$FOLDER/favicon.png" -background "#FFFFFF" -alpha background "$FOLDER/favicon.jpg"

	convert "$FOLDER/favicon.png" -define icon:auto-resize=256,128,96,64,48,32,16 "$FOLDER/favicon.ico"

	convert "$FOLDER/favicon.png" -resize 192x192 "$FOLDER/apple-icon.png"
	convert "$FOLDER/favicon.png" -resize 192x192 "$FOLDER/apple-icon-precomposed.png"
	convert "$FOLDER/favicon.jpg" -resize 1024x1024 "$FOLDER/apple-touch-icon.png"
	convert "$FOLDER/favicon.jpg" -resize 167x167 "$FOLDER/touch-icon-ipad-retina.png"
	convert "$FOLDER/favicon.png" -resize 16x16 "$FOLDER/favicon-16x16.png"
	convert "$FOLDER/favicon.png" -resize 32x32 "$FOLDER/favicon-32x32.png"
	convert "$FOLDER/favicon.png" -resize 96x96 "$FOLDER/favicon-96x96.png"
	convert "$FOLDER/favicon.png" -resize 196x196 "$FOLDER/favicon-196x196.png"
	convert "$FOLDER/favicon.png" -resize 228x228 "$FOLDER/favicon-228x228.png"
	convert "$FOLDER/favicon.png" -resize 57x57 "$FOLDER/apple-icon-57x57.png"
	convert "$FOLDER/favicon.png" -resize 60x60 "$FOLDER/apple-icon-60x60.png"
	convert "$FOLDER/favicon.png" -resize 72x72 "$FOLDER/apple-icon-72x72.png"
	convert "$FOLDER/favicon.png" -resize 76x76 "$FOLDER/apple-icon-76x76.png"
	convert "$FOLDER/favicon.png" -resize 114x114 "$FOLDER/apple-icon-114x114.png"
	convert "$FOLDER/favicon.png" -resize 120x120 "$FOLDER/apple-icon-120x120.png"
	convert "$FOLDER/favicon.png" -resize 144x144 "$FOLDER/apple-icon-144x144.png"
	convert "$FOLDER/favicon.png" -resize 152x152 "$FOLDER/apple-icon-152x152.png"
	convert "$FOLDER/favicon.png" -resize 180x180 "$FOLDER/apple-icon-180x180.png"
	convert "$FOLDER/favicon.png" -resize 70x70 "$FOLDER/ms-icon-70x70.png"
	convert "$FOLDER/favicon.png" -resize 144x144 "$FOLDER/ms-icon-144x144.png"
	convert "$FOLDER/favicon.png" -resize 150x150 "$FOLDER/ms-icon-150x150.png"
	convert "$FOLDER/favicon.png" -resize 310x310 "$FOLDER/ms-icon-310x310.png"
	convert "$FOLDER/favicon.png" -resize 48x48 "$FOLDER/android-icon-48x48.png"
	convert "$FOLDER/favicon.png" -resize 72x72 "$FOLDER/android-icon-72x72.png"
	convert "$FOLDER/favicon.png" -resize 36x36 "$FOLDER/android-icon-36x36.png"
	convert "$FOLDER/favicon.png" -resize 96x96 "$FOLDER/android-icon-96x96.png"
	convert "$FOLDER/favicon.png" -resize 144x144 "$FOLDER/android-icon-144x144.png"
	convert "$FOLDER/favicon.png" -resize 192x192 "$FOLDER/android-icon-192x192.png"
	convert "$FOLDER/favicon.jpg" -resize 57x57 "$FOLDER/touch-icon-iphone-57x57.png"
	convert "$FOLDER/favicon.jpg" -resize 60x60 "$FOLDER/touch-icon-iphone-60x60.png"
	convert "$FOLDER/favicon.jpg" -resize 114x114 "$FOLDER/touch-icon-iphone-114x114.png"
	convert "$FOLDER/favicon.jpg" -resize 120x120 "$FOLDER/touch-icon-iphone-120x120.png"
	convert "$FOLDER/favicon.jpg" -resize 180x180 "$FOLDER/touch-icon-iphone-180x180.png"
	convert "$FOLDER/favicon.jpg" -resize 72x72 "$FOLDER/touch-icon-ipad-72x72.png"
	convert "$FOLDER/favicon.jpg" -resize 76x76 "$FOLDER/touch-icon-ipad-76x76.png"
	convert "$FOLDER/favicon.jpg" -resize 144x144 "$FOLDER/touch-icon-ipad-144x144.png"
	convert "$FOLDER/favicon.jpg" -resize 152x152 "$FOLDER/touch-icon-ipad-152x152.png"
else
	echo "Usage: makeicons.sh /path/to/folder/that/contains/favicon/"
fi
