Hallo Ulf,
ist kein schöner code, also nicht meckern: ;-)
<?
Textposition
$tx = 9;
$ty = 7;
Dimension
$MaxX = 70;
$MaxY = 30;
Bild erstellen
header("Content-type: image/png");
$im = @imagecreate($MaxX,$MaxY);
Farben definieren
$white = @ImageColorAllocate($im, 255,255,255);
$red = @ImageColorAllocate($im, 255,0,0);
$green = @ImageColorAllocate($im, 0,255,0);
$gray = @ImageColorAllocate($im, 128,128,128);
$lightgray = @ImageColorAllocate($im, 224,224,224);
$lightblue = @ImageColorAllocate($im, 128,128,255);
@ImageColorTransparent($im, $white); # weiß = transparent
$tcol = explode(",",$tcolor);
$text_color = @ImageColorAllocate($im, $tcol[0], $tcol[1], $tcol[2]);
$bcol = explode(",",$bcolor);
$border_color = @ImageColorAllocate($im, $bcol[0], $bcol[1], $bcol[2]);
$strng='';
for ($i=1; $i<=6;) # Anzahl der Zeichen
{
mt_srand((double)microtime()*1000000);
$char = mt_rand(48,122);
if($char>47 && $char<58 || $char>64 && $char<91 || $char>96 && $char<123)
{
$strng.=chr($char);
$i++;
}
}
@imagefill($im, 0, 0, $lightgray);
Rahmen und Logo setzen
@imagerectangle($im, 0, 0, $MaxX-1, $MaxY-1, $border_color);
@imagestring($im, 5, $tx, $ty, $strng, $text_color);
@imagepng($im);
?>
freundl. Grüße aus Berlin, Raik