I'm looking for a PHP library/function/class which can create Identicons.
-
1what is the difference between identicons and gravatars? – balexandre Oct 25 '08 at 22:49
-
A gravatar is a user selected image - identicons are generated based on an ip address or email address. identicons / monsterids / visiglyphs are sometimes used as a fallback if no gravatar is available. – jimg Nov 24 '08 at 16:03
-
I haven't tested, but the 4th result when searching for "Identicon php": http://www.phpkode.com/scripts/item/php-identicons/ – TheHippo Apr 16 '13 at 00:51
5 Answers
i use this:
class Gravatar
{
static public function GetGravatarUrl( $email, $size = 128, $type = 'identicon', $rating = 'pg' )
{
$gravatar = sprintf( 'http://www.gravatar.com/avatar/%s?d=%s&s=%d&r=%s',
md5( $email ), $type, $size, $rating );
return $gravatar;
}
}
Which is basically the same thing SO uses. It supports everything gravatar.com supports.

- 40,604
- 9
- 72
- 101
how about this
it's how Scott did the identicons for Wordpress, you can download the code and see for yourself.
Hope it helps.

- 73,608
- 45
- 233
- 342
PHPClasses didn't have anything - but you could have a look at this MonsterID implementation.

- 46,186
- 39
- 120
- 173
Mmm, I wondered why you asked, since you link to Wikipedia article which points to lot of implementations, including PHP ones. BTW, thanks for your question, I didn't know the name of these icons...
But after exploring a bit, I found lot of links there were outdated... Following the Visiglyphs one, the original code is no longer available, but the author points to an alternative, OO version which can be downloaded. :-)
Note that author also wrote an interesting complement article: How to create a Visiglyph cache .

- 40,535
- 6
- 96
- 134