Skip to content

Instantly share code, notes, and snippets.

@wunderkind2k1
Last active June 27, 2022 07:21
Show Gist options
  • Save wunderkind2k1/7e7d9010f2a492a3db5d6ed9aefd0d6b to your computer and use it in GitHub Desktop.
Save wunderkind2k1/7e7d9010f2a492a3db5d6ed9aefd0d6b to your computer and use it in GitHub Desktop.
A shell script to download a gravatar image for an email in a given size as jpg
#!/bin/bash
if [ -z "$1" ];
then
echo "pls provide mail"
exit 1
else
mail=$1
fi
if [ -z "$2" ];
then
#default
size=200
else
size=$2
fi
downloadUrl="https://gravatar.com/avatar/"$(md5 -s $mail | cut -d " " -f 4)"?s=$size"
curl -s -o "${mail}_${size}.jpg" $downloadUrl
@bonelifer
Copy link

Tried this on Ubuntu but it can't find md5.

@bonelifer
Copy link

bonelifer commented Jun 25, 2022

Changed to use Ubuntu's md5sum. Also fetches the QRCODE.

#!/bin/bash
if [ -z "$1" ];
then
	echo "pls provide mail"
	exit 1
else
  mail=$1
fi
if [ -z "$2" ];
then
#default
 size=200
else
 size=$2
fi

md5=`echo -n $mail | md5sum  | sed -En 's/  -//p'`
echo $md5
downloadUrl="https://en.gravatar.com/avatar/"$md5"?s=$size"
downloadQR="https://en.gravatar.com/$md5.qr?s=200"

curl -s -o "${mail}_${size}.jpg"  $downloadUrl
curl -s -o "${mail}_${md5}.jpg" $downloadQR

@wunderkind2k1
Copy link
Author

Thx! Love it. My script runs on OSX (forgot to mention it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment