*

Zootool Default Avatars

When I started working on the new version of Zootool I was so fed up of having boring default avatars. They ruin every design, they are super anonymous and they just suck even if you come up with some crazy creative default avatar design. 

I’d been working with Arno Richter on a wiki project for our faculty in University years ago and we generated random pixelated header images out of all the user uploaded pictures. It worked like a charm and looked pretty stylish.

So one day the idea came up to adapt that concept for the Zootool default avatars. It took me about one hour to implement and the result was really cool. After half a year the whole thing still works great, so here’s a little insight on how it is done:

When I started this Zootool had about 200,000 entries in the database – most of them with decent previews. So all I have to do when a new user signs up, is to get a random entry and make sure it has a thumbnail. Here’s a simplified version of the query I’m using for this: 

SELECT thumb FROM entries WHERE thumb_exists = ‘y’ ORDER BY RAND() LIMIT 1

You actually shouldn’t do the ORDER BY RAND() stuff on large tables and I use a different approach for that, but that’s another story :)

All I got to do next is to crop and scale that thumbnail down to 4x4 pixels and scale it up again, using the nearest neighbor algorithm and – tadaa – there’s a nice random default avatar for the new user.

The following code is again a simplified version. You can customize it for your own needs however you like.

2010-08-04
Tweet this