Bild erzeugen
Jimmy
- php
1 wahsaga
Wie erzeuge ich ein Bild auf dem Server (datei.jpg) und nicht im Browser wie mit diesem Script:
<?
SESSION_START();
$tx = 9;
$ty = 7;
$MaxX = 70;
$MaxY = 30;
header("Content-type: image/png");
$im = @imagecreate($MaxX,$MaxY);
$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++;
}
}
$_SESSION['secure']=$strng;
@imagefill($im, 0, 0, $lightgray);
@imagerectangle($im, 0, 0, $MaxX-1, $MaxY-1, $border_color);
@imagestring($im, 5, $tx, $ty, $strng, $text_color);
@imagepng($im);
?>
Vielen Dank
hi,
Wie erzeuge ich ein Bild auf dem Server (datei.jpg) und nicht im Browser wie mit diesem Script:
@imagepng($im);
schau dir im manual an, was man mit dieser funktion noch machen kann, außer die bilddaten direkt auszugeben, und wie.
btw: die vielen @ vor den funktionsaufrufen sollte man zum testen entfernen, wenn man ggf. auch fehlermeldungen angezeigt bekommen möchte.
gruß,
wahsaga