Skip to content

Instantly share code, notes, and snippets.

@Gussi
Forked from nateware/make_favicon.sh
Last active May 22, 2017 16:35
Show Gist options
  • Save Gussi/14ca139479acd71f7685a26931a77c60 to your computer and use it in GitHub Desktop.
Save Gussi/14ca139479acd71f7685a26931a77c60 to your computer and use it in GitHub Desktop.
Imagemagick to create favicon.ico with 16x16 and 32x32 sizes in it
#!/bin/sh
# Generate bunch of favicons
if [ $# -ne 1 ]; then
echo USAGE: $0 favicon-original.png
exit 1
fi
ORIGINAL=$1
# IE dumb favicons
convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 ${ORIGINAL} output-16x16.ico
convert -resize x32 -gravity center -crop 32x32+0+0 -flatten -colors 256 ${ORIGINAL} output-32x32.ico
convert output-16x16.ico output-32x32.ico favicon.ico
rm output-16x16.ico output-32x32.ico
echo '<link rel="shortcut icon" href="/favicon.ico" sizes="32x32" />'
# Apple favicons
for SIZE in 180 152 144 120 114 76 72 60 57
do
convert -resize x${SIZE} ${ORIGINAL} apple-touch-icon-${SIZE}x${SIZE}.png
echo "<link rel=\"apple-touch-icon\" sizes=\"${SIZE}x${SIZE}\" href=\"apple-touch-icon-${SIZE}x${SIZE}.png\" />"
done
# Normal favicons
for SIZE in 192 160 96 32 16
do
convert -resize x${SIZE} ${ORIGINAL} favicon-${SIZE}x${SIZE}.png
echo "<link rel=\"icon\" type=\"image/png\" sizes=\"${SIZE}x${SIZE}\" href=\"favicon-${SIZE}x${SIZE}.png\" />"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment