Вопрос

I frequently see the following kind of images on many websites (on StackOverflow for example).

What is this kind of image called and how do I generate it? (preferably in PHP)

Это было полезно?

Решение 3

Just google 'gravatar'.... (as an alternative to what u wanted)

Другие советы

Duplicate question, but here is more to read about: http://en.wikipedia.org/wiki/Identicon

Using GD library and this source http://sourceforge.net/projects/identicons/ for PHP

Quote from wiki, for those who are lazy to open the link:

An Identicon is a visual representation of a hash value, usually of an IP address, that serves to identify a user of a computer system as a form of avatar while protecting the users' privacy. The original Identicon was a 9-block graphic, and the representation has been extended to other graphic forms by third parties.

You can a try this code something similar to your above query. [Not a direct answer though]

<?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);
?>

Generates a random color each and every time like this.

enter image description here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top