Last active
June 27, 2022 07:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
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
Tried this on Ubuntu but it can't find md5.