I hereby announce the release of Surrogator version 0.1.0, a simple Libravatar compatible avatar image server written in PHP.
Libravatar?
You probably know Gravatar, the (proprietary) service by the Wordpress.com guys. You give it the md5 hash of an email address and get an image for it - given that the person owning the email address registered there and uploaded a picture.
Many many blog and web applications use those images to give comments a personal note and make it easy to recognize the commenters.
Libravatar (libre avatar) does basically the same, but has some huge benefits:
- It is federated, which means that you can host your own avatar server for your domains. In case Libravatar.org or Gravatar are down, images for your email addresses will still be delivered.
- You can use it as a service like Gravatar if you don't want to host your own server. But unlike Gravatar - which you cannot leave - you have full control over your avatars and your account. Full account export and removal are supported.
- You can assign images to OpenIDs.
- It is open source. The Libravatar sources are open for anyone to inspect, improve and install on your own server.
- It falls back to Gravatar. The userbase of Gravatar is not to be neglected, so Libravatar falls back to the Gravatar image if there is no Libravatar one.
- You do not have to register another account but may login with your OpenID.
Surrogator?
The original Libravatar software is written in Python and contains the whole package: Profiles, login, image upload, email and OpenID management.
I do not need all that; all I want is to put an image file foo@example.org.png somewhere, and that's it. This is Surrogator.
Just download (or git clone) Surrogator, follow the 4 setup steps, put the image files in the raw/ directory and that's it. It just works and takes little server resources.
Services_Libravatar
So Libravatar is cool, how can you use it? Luckily, Melissa Draper wrote the Services_Libravatar library which is documented and easily installable via PEAR or Pyrus:
$ pear install services_libravatar-alpha
Using it is as easy as writing four lines of code:
<?php require_once 'Services/Libravatar.php'; $sla = new Services_Libravatar(); $imgUrl = $sla->getUrl('foo@example.org'); echo '<img alt="Avatar" src="' . htmlspecialchars($imgUrl) . '"/>';
That's it. Now start using free avatar images in your software, and use one of the available plugins.