A bash script to create a favicon.ico via Imagemagick.
Usage:
./favicon.sh myimage.pngCreates a favicon.ico file in the same folder.
A bash script to create a favicon.ico via Imagemagick.
Usage:
./favicon.sh myimage.pngCreates a favicon.ico file in the same folder.
| #!/bin/bash | |
| set -e | |
| # | |
| # Create a favicon.ico from any image | |
| # | |
| # requires Imagemagick | |
| # https://legacy.imagemagick.org/Usage/thumbnails/#favicon | |
| # | |
| if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | |
| #-- Help | |
| if [ -z "$1" ]; then | |
| echo | |
| echo "Error: image file required" | |
| fi | |
| echo | |
| echo "Usage: \"$0 <image>\"" | |
| echo " image - Can be any image file, but square PNGs work best." | |
| echo | |
| exit | |
| fi | |
| convert $1 -background white \ | |
| \( -clone 0 -resize 16x16 -extent 16x16 \) \ | |
| \( -clone 0 -resize 32x32 -extent 32x32 \) \ | |
| \( -clone 0 -resize 48x48 -extent 48x48 \) \ | |
| \( -clone 0 -resize 64x64 -extent 64x64 \) \ | |
| -delete 0 -alpha off -colors 256 favicon.ico |