Skip to content

Instantly share code, notes, and snippets.

@croaky
Created March 10, 2020 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save croaky/be85d1d8abffc372b42b47777903b269 to your computer and use it in GitHub Desktop.
Save croaky/be85d1d8abffc372b42b47777903b269 to your computer and use it in GitHub Desktop.
Make a circular favicon from your GitHub avatar
#!/bin/bash
# Make a circular favicon from your GitHub avatar
#
# ./favicon.sh username
set -eu
if ! command -v convert >/dev/null; then
echo "error: ImageMagick isn't installed." >&2
exit 1
fi
if [ $# -eq 0 ]; then
echo "error: No GitHub username provided." >&2
exit 1
fi
curl -L "https://github.com/$1.png?size=32" -o input.jpg
convert input.jpg \
-gravity Center \
\( -size 32x32 \
xc:Black \
-fill White \
-draw 'circle 16 16 16 1' \
-alpha Copy \
\) -compose CopyOpacity -composite \
-trim favicon.ico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment