Surrogator - free avatar image server

Avatar for cweiske 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:

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.

Written by Christian Weiske.

Comments? Please send an e-mail.