SO 上的用户 ID 图像是如何生成的?
我对这个网站上与每个用户相关的可爱的小万花筒图像有点好奇。 这些是如何生成的? 可能性是:
- 图像列表已经存在于某个文件夹中,并且是随机选择的。
- 每当用户注册时都会生成图像。
无论如何,我更感兴趣的是用什么样的算法来生成这样的图像。
I am a little curious about the cute little kaleidoscopic images associated with each user on this site.
How are those generated? Possibilities are:
- A list of images is already there in some folder and it is chosen randomly.
- 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
它称为 Identicon。 如果您输入了电子邮件,则它基于您的电子邮件地址的哈希值。 如果您没有输入电子邮件,则它基于您的 IP 地址。
Jeff 发布了一些 .NET 代码来生成基于 IP 的标识符。
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.
它通常是根据用户名、电子邮件地址或 IP 地址的哈希值生成的。
Stackoverflow 使用 Gravatar 来生成图像。
据我所知,这个想法来自 Don Parks,他撰写了有关他使用的技术的文章。
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.
IIRC,它是从 IP 地址生成的。
我相信它被称为“IP 哈希”。
我记得在博客上读过相关内容; 他提供了代码供下载。 然而我不知道它是从哪里来的。 :(
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. :(
这些图像由 Gravatar 制作,详细信息为
The images are produced by Gravatar and details of them are outlined here, however, they do not reveal how they are doing it.
我敢打赌,每个小图块图像都会被赋予一组看起来不错的其他图块图像。 想象一个以图块为节点的图表。 您为角点随机选择一个节点,并用伙伴填充它的相邻点,然后旋转它并应用相同的图案四次。 然后选择一种颜色。
它也可以不是图形,而是方阵,其中每行代表一个图像,每列代表一个图像,单元格值是权重。
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.
我相信这些图像是一个 4×4 网格,上面的 2×2 网格顺时针重复 4 次,只是每次旋转 90 度,再次顺时针旋转。 似乎两种颜色是随机选择的,并且每个 1×1 块都是从预定义的集合中选择的。
编辑:显然我的回答是临时的。 很高兴了解身份标识。
试试这个:http://www.docuverse.com/blog/9block? code=(32-bitinteger)8&size=(16|32|64)
用适当的数字替换括号内的项目。
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.