codice:
<?php
if( GDVersion() ){
header("Content-type: image/png");
if( GDVersion() == 1 ){
$im = @imagecreate(300, 255) or die("Cannot Initialize new GD image stream");
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
imagefilledrectangle($im, 0, 0, 51, 300, $white);
imagefilledrectangle($im, 51, 0, 102, 300, $red);
imagefilledrectangle($im, 102, 0, 153, 300, $green);
imagefilledrectangle($im, 153, 0, 204, 300, $blue);
imagefilledrectangle($im, 204, 0, 255, 300, $black);
}
else{
$im = @imagecreatetruecolor(300, 255) or die("Cannot Initialize new GD image stream");
for( $i = 0; $i < 256; $i++ ){
$col = imagecolorallocate($im, 255, $i, $i);
imagefilledrectangle($im, 0, $i, 100, $i+1, $col);
}
for( $i = 255; $i > -1; $i-- ){
$col = imagecolorallocate($im, $i, 255, $i);
imagefilledrectangle($im, 100, 255-$i, 200, 256-$i, $col);
}
for( $i = 0; $i < 256; $i++ ){
$col = imagecolorallocate($im, $i, $i, 255);
imagefilledrectangle($im, 200, $i, 300, $i+1, $col);
}
}
$grey = imagecolorallocate($im, 100, 100, 100);
imageString($im, 5, 120, 100, 'GD ' . GDVersion(), $grey);
imagepng($im);
imagedestroy($im);
}
else{
echo 'Errore, libreria GD non disponibile su questo sistema!';
}
?>
Nient'altro.