10

I am a little curious about the cute little kaleidoscopic images associated with each user on this site. How are those generated? Possibilities are:

  1. A list of images is already there in some folder and it is chosen randomly.
  2. The image is generated whenever a user registers.

In any case, I am more interested in what kind of algorithm is used to generate such images.

Hank Gay
  • 70,339
  • 36
  • 160
  • 222
nullDev
  • 11,170
  • 8
  • 34
  • 52
  • 1
    I believe the question is referring to the images (identicons) used when the user doesn't have a gravatar. – Hank Gay Sep 19 '08 at 13:48

6 Answers6

13

It's called an Identicon. If you entered and e-mail, it's a based on a hash of your e-mail address. If you didn't enter an e-mail, it's based on your IP address.

Jeff posted some .NET code to generate IP based Identicons.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Chris Upchurch
  • 15,297
  • 6
  • 51
  • 66
5

Its usually generated from a hash of either a user name, email address or ip address.

Stackoverflow uses Gravatar to do the image generation.

As far as I know the idea came from Don Parks, who writes about the technique he uses.

Matt Howells
  • 40,310
  • 20
  • 83
  • 102
1

IIRC, it's generated from an IP address.

"IP Hashing" I believe it's called.

I remember reading about it on a blog; he made the code available for download. I have no idea where it was from, however. :(

TraumaPony
  • 10,742
  • 12
  • 54
  • 74
1

The images are produced by Gravatar and details of them are outlined here, however, they do not reveal how they are doing it.

GateKiller
  • 74,180
  • 73
  • 171
  • 204
0

I believe the images are a 4×4 grid with the upper 2×2 grid repeated 4 times clockwise, just each time rotated 90 degrees, again clockwise. Seems the two colours are chosen randomly, and each 1×1 block is chosen from a predefined set.

EDIT: obviously my answer was ad hoc. Nice to know about identicons.

Try this: http://www.docuverse.com/blog/9block?code=(32-bit integer)8&size=(16|32|64)

substituting appropriate numbers for the parenthesized items.

tzot
  • 92,761
  • 29
  • 141
  • 204
0

I bet each tiny tile image is given a set of other tile images it looks good with. Think of a graph with the tiles as nodes. You pick a random node for the corner and fill it's adjacent spots with partners, then rotate it and apply the same pattern four times. Then pick a color.

Instead of a graph, it could also be a square matrix in which each row represents an image, each column represents an image, and cell values are weights.

easeout
  • 8,665
  • 5
  • 43
  • 51