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 = 'http://robohash.org/%s.png?size=%sx%s&bgset=any' % (hash, size, size)
avatar_url = 'http://www.gravatar.com/avatar/%s?s=%s&d=%s' % (hash, size, robohash_url)

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

Posted . Categories: .