Skip to content

Instantly share code, notes, and snippets.

@aitseitz
Last active December 21, 2021 16:41
Show Gist options
  • Save aitseitz/a6d1be02950de9ebf012e9f58c819a12 to your computer and use it in GitHub Desktop.
Save aitseitz/a6d1be02950de9ebf012e9f58c819a12 to your computer and use it in GitHub Desktop.
generateFaviconFromSVG.sh
#!/bin/bash
# Sources:
# https://github.com/audreyr/favicon-cheat-sheet
# https://graphicdesign.stackexchange.com/questions/77359/how-to-convert-a-square-svg-to-all-size-ico
set -ex
svg=$1
size=(16 24 32 48 64 76 96 128 144 152 196)
echo "=== Making a Favicon by using PNGs generated from the the svg ${svg} === "
echo ""
echo "Generating PNGs..."
for i in ${size[@]}; do
inkscape $svg --export-png="favicon-${i}x${i}.png" -w$i -h$i --without-gui
done
echo "Compressing..."
## Replace with your favorite (e.g. pngquant)
optipng -o7 favicon-*.png
# pngquant -f --ext .png favicon-*.png --posterize 4 --speed 1
echo "Converting to favicon.ico..."
convert $(ls -v favicon-*.png) favicon.ico
## Clean-up maybe?
# rm favicon-*.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment