For a few reasons, I really dislike the letter based avatars automatically generated by the forums.
I would like to propose a PHP script that builds random avatars from a URL. For example: entering /blablabla.com/avatar.png in the forum’s avatar URL setting would generate a new random avatar on each new user registration. The avatar URL setting is built-in, so we just need to write the script.
http://php.net/manual/en/function.imagecreatefrompng.php
(PHP 4, PHP 5, PHP 7)
imagecreatefrompng — Create a new image from file or URL
Example:
<?php
function LoadPNG($imgname)
{
/* Attempt to open */
$im = @imagecreatefrompng($imgname);
/* See if it failed /
if(!$im)
{
/ Create a blank image */
$im = imagecreatetruecolor(150, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an error message */
imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
}
return $im;
}header(‘Content-Type: image/png’);
$img = LoadPNG(‘bogus.image’);
imagepng($img);
imagedestroy($img);
?>
Rather than a text overlay as in the example above, the script would overlay an image (with transparency) over another background image.
The other main difference would be that we would hard-code maybe 10 or 20 PNG images for the foreground and 5-10 for the background. Perhaps these would be in an array, and a random combination would be chosen each time the URL is called.
The output size would be consistent, and the sizing of the input images could be made to match in advance.
I suspect this script could be written by someone who knows PHP in less time than it took me to write this, but it’s also possible I’m overlooking a limitation in this function.
: