Created
July 27, 2014 06:27
-
-
Save lavoiesl/a7ccb4affe869d0a0bca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Converts an image in a multi-resolution favicon | |
# Requires Imagemagick | |
# | |
# @link https://gist.github.com/lavoiesl/a7ccb4affe869d0a0bca | |
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}" -resize "${size}x${size}" -background transparent -colors 256 -flatten "${file}" | |
files="${files} ${file}" | |
done | |
convert "${files}" "${output}" | |
rm -R "${tmp_dir}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment