【发布时间】:2013-09-01 11:47:12
【问题描述】:
我经常在许多网站(例如 StackOverflow)上看到以下类型的图片。
这种图像叫什么?如何生成它? (最好在 PHP 中)
【问题讨论】:
我经常在许多网站(例如 StackOverflow)上看到以下类型的图片。
这种图像叫什么?如何生成它? (最好在 PHP 中)
【问题讨论】:
重复的问题,但这里有更多要阅读的内容:http://en.wikipedia.org/wiki/Identicon
使用 GD 库和这个源代码 http://sourceforge.net/projects/identicons/ 用于 PHP
来自wiki的引述,对于那些懒得打开链接的人:
Identicon 是哈希值(通常是 IP 地址)的可视化表示,用于将计算机系统的用户识别为一种虚拟形象,同时保护用户的隐私。最初的 Identicon 是一个 9 块图形,并且表示已被第三方扩展为其他图形形式。
【讨论】:
您可以尝试使用与上述查询类似的代码。 [虽然不是直接的答案]
<?php
$Width = 64;
$Height = 64;
$Image = imagecreate($Width, $Height);
for($Row = 1; $Row <= $Height; $Row++) {
for($Column = 1; $Column <= $Width; $Column++) {
$Red = mt_rand(0,255);
$Green = mt_rand(0,255);
$Blue = mt_rand(0,255);
$Colour = imagecolorallocate ($Image, $Red , $Green, $Blue);
}
}
header('Content-type: image/png');
imagepng($Image);
?>
每次都像这样生成随机颜色。
【讨论】:
只需 google 'gravatar'....(作为您想要的替代品)
【讨论】: