RoboHash and Gravatar

I recently discovered a charming web service called RoboHash which returns an image of a robot deterministically as a function of some input text. Take a gander at a smattering of random robots:

These would make an awesome fallback as an avatar for those without a Gravatar set up, since it will always give you the same robot if you enter the same email address. So of course I implemented it for this site!

The Python to build a Gravatar URL which will fallback properly is roughly as follows:

import hashlib
size = 45
hash = hashlib.md5(email.strip().lower()).hexdigest()
robohash_url = '' % (hash, size, size)
avatar_url = '' % (hash, size, robohash_url)

Leave a comment on this post to see what your robot looks like!

Posted . Categories: .