Skip to content

Instantly share code, notes, and snippets.

@chromy
Created June 25, 2013 17:32
Show Gist options
  • Save chromy/5860496 to your computer and use it in GitHub Desktop.
Save chromy/5860496 to your computer and use it in GitHub Desktop.
A bash scrip to get your Gravatar and save it as an image and a favicon.
#!/bin/bash
# This script downloads a gravatar image associated with EMAIL and saves it at
# AVATAR_OUTPUT_PATH then creates a favicon icon and saves it at
# FAVICON_OUTPUT_PATH.
EMAIL="hector.dearman@gmail.com"
AVATAR_OUTPUT_PATH="static/img/avatar.png"
FAVICON_OUTPUT_PATH="static/favicon.ico"
# https://en.gravatar.com/site/implement/hash/
function email_to_hash {
echo -n $1 | tr '[A-Z]' '[a-z]' | md5
}
# Stop on error.
set -e
email_hash=$(email_to_hash $EMAIL)
# https://en.gravatar.com/site/implement/images/
wget http://www.gravatar.com/avatar/$email_hash?size=512 -O $AVATAR_OUTPUT_PATH
# http://www.imagemagick.org/Usage/thumbnails/#favicon
convert $AVATAR_OUTPUT_PATH -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
-delete 0 -alpha off -colors 256 $FAVICON_OUTPUT_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment