Codice PHP:
<?php
$nickname="a1";
$rango="Alterguru";
//settaggio dimensione bordi
$h1=10;
$h2=30;
//settaggio dimensioni immagine
//(serve per impostare i bordi...)
list($w, $h) = getimagesize($nickname.".gif");
//caricamento immagine jpg per la figurina
$imgname=$nickname.".gif";
$im = imagecreatefromgif ($imgname);
if (!$im) { /* See if it failed */
$im = imagecreate ($h, $w); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
// some colors
$blue = imagecolorallocate($im, 0, 0, 255);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$bluav = imagecolorallocate($im, 0x00, 0x00, 0x80);
$gialloav1 = imagecolorallocate($im, 0xDC, 0xDC, 0x00);
$gialloav2 = imagecolorallocate($im, 0x80, 0x80, 0x00);
// disegno dei bordi
//bordo verticale sx
imagefilledrectangle($im,0,0,$h1,$h,$white );
//bordo orizzontale sopra
imagefilledrectangle($im,0,0,$w,$h2,$white );
//bordo verticale dx
imagefilledrectangle($im,($w-$h1),0,$w,$h,$white );
//bordo orizzontale sotto
imagefilledrectangle($im,0,($h-$h2),$w,$h,$white );
//disegno ombreggiatura interna bordi
imagefilledrectangle($im,$h1,$h2,$h1,($h-$h2),$black );
imagefilledrectangle($im,$h1,$h2,($w-$h1),$h2,$black );
//disegno dello spazio per il rango
imagefilledrectangle($im,0,($h-($h2+20)),($w-($h1+10)),($h-($h2+5)),$white );
//disegno dello spazio per il nome
imagefilledrectangle($im,($h1+10),($h-($h2+40)),$w,($h-($h2+25)),$white );
//disegno delle ombre su spazio per nome
imageline($im, ($h1+10), ($h-($h2+25)),($w-$h1),($h-($h2+25)), $black);
//disegno delle ombre su spazio per grado
imageline($im, ($w-($h1+10)), ($h-($h2+20)),($w-($h1+10)),($h-($h2+5)), $black);
imageline($im,$h1,($h-($h2+5)),($w-($h1+10)),($h-($h2+5)),$black );
//disegno del logo di altervista
// disegno della base del logo
imagefilledrectangle($im,($h1+7),($h-($h2+26)),($h1+7+14),($h-($h2+11)),$bluav);
//disegno parti con colore gialloav1
imagefilledrectangle($im,($h1+7+2),($h-($h2+(26-2))),($h1+7+6),($h-($h2+(26-4))),$gialloav1);
imagefilledrectangle($im,($h1+7+7),($h-($h2+(26-2))),($h1+7+7),($h-($h2+(26-2))),$gialloav1);
imagefilledrectangle($im,($h1+7+6),($h-($h2+(26-4))),($h1+7+6),($h-($h2+(26-7))),$gialloav1);
imagefilledrectangle($im,($h1+7+10),($h-($h2+(26-2))),($h1+7+11),($h-($h2+(26-12))),$gialloav1);
imagefilledrectangle($im,($h1+7+9),($h-($h2+(26-6))),($h1+7+9),($h-($h2+(26-12))),$gialloav1);
imagefilledrectangle($im,($h1+7+2),($h-($h2+(26-8))),($h1+7+4),($h-($h2+(26-12))),$gialloav1);
imagefilledrectangle($im,($h1+7+5),($h-($h2+(26-11))),($h1+7+5),($h-($h2+(26-12))),$gialloav1);
imagefilledrectangle($im,($h1+7+6),($h-($h2+(26-12))),($h1+7+8),($h-($h2+(26-12))),$gialloav1);
//parti in gialloav2
imagefilledrectangle($im,($h1+7+2),($h-($h2+(26-13))),($h1+7+12),($h-($h2+(26-13))),$gialloav2);
imagefilledrectangle($im,($h1+7+7),($h-($h2+(26-3))),($h1+7+7),($h-($h2+(26-6))),$gialloav2);
imagefilledrectangle($im,($h1+7+6),($h-($h2+(26-8))),($h1+7+6),($h-($h2+(26-8))),$gialloav2);
imagefilledrectangle($im,($h1+7+12),($h-($h2+(26-2))),($h1+7+12),($h-($h2+(26-13))),$gialloav2);
//scrittura nome
imagestring($im, 8,($h1+50),($h-($h2+40)), $nickname, $bluav);
//scrittura rango
//$rango="Alterguru";
imagestring($im, 8,($h1+30),($h-($h2+21)), $rango, $bluav);
// flush image
header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);
?>