How is the user id image generated on SO?

帅比萌擦擦* 提交于 2019-12-21 04:07:15

问题


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.


回答1:


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.




回答2:


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.




回答3:


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. :(




回答4:


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




回答5:


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.




回答6:


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.



来源:https://stackoverflow.com/questions/101918/how-is-the-user-id-image-generated-on-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!