Circular Favicon from GitHub Avatar

I wrote a script to generate a circular favicon and Apple Touch icon from my GitHub avatar and generalized it.

Make sure ImageMagick is installed. On macOS:

brew install imagemagick

Copy the script into a file named

set -eu

if ! command -v convert >/dev/null; then
  echo "error: ImageMagick isn't installed." >&2
  exit 1

if [ $# -eq 0 ]; then
  echo "error: No GitHub username provided." >&2
  exit 1

curl -L "$1.png?size=32" -o input.png

convert input.png \
  -gravity Center \
  \( -size 32x32 \
    xc:Black \
    -fill White \
    -draw 'circle 16 16 16 1' \
    -alpha Copy \
  \) -compose CopyOpacity -composite \
  -trim favicon.ico

curl -L "$1.png?size=180" -o apple-touch-icon.png

Make it executable:

chmod +x

Run it with your GitHub username:

./ username

These files will be created: