Skip to content

Instantly share code, notes, and snippets.

@lavoiesl
Last active October 13, 2015 00:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save lavoiesl/4113857 to your computer and use it in GitHub Desktop.
Save lavoiesl/4113857 to your computer and use it in GitHub Desktop.
Generate a multi resolution file
#!/bin/bash
# Converts an image in a multi-resolution favicon
# Requires Imagemagick
# @link https://gist.github.com/lavoiesl/4113857
if [[ "$#" != "2" ]]; then
echo "Usage: $0 input.png output.ico" >&2
exit 1
fi
input="$1"
output="$2"
sizes="16 32 64 128 256"
tmp_dir=$(mktemp -d /tmp/favicon.XXXXXXXXXX)
files=""
for size in $sizes; do
file="$tmp_dir/$size.png"
convert "$input" -depth 8 -background transparent -flatten -resize "${size}x${size}" "$file"
files="$files $file"
done
convert $files $output
rm -R $tmp_dir
@simonewebdesign
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment