Hallo,
ich baue mir gerade ein eigenes Captcha, zumindest versuche ich es. Zu Beginn habe ich mir einfach Text als Grafik ausgegeben über die Funktion imagestring. Das funktioniert auch fehlerfrei. Aber die Funktion imagettftext funktioniert nicht ich weiß nicht warum. Hat jemand eine Idee?
Hier das kurze Script, um die Grafik zu erzeugen:
$code=rand(1000,9999);
$_SESSION["code"]=$code;
$bg_path = "/images/backgrounds/";
$backgrounds = array(
$bg_path . '45-degree-fabric.png',
$bg_path . 'cloth-alike.png',
$bg_path . 'grey-sandbag.png',
$bg_path . 'kinda-jean.png',
$bg_path . 'polyester-lite.png',
$bg_path . 'stitched-wool.png',
$bg_path . 'white-carbon.png',
$bg_path . 'white-wave.png');
$background = $backgrounds[mt_rand(0, count($backgrounds) -1)];
$angle = mt_rand( 0, 10 ) * (mt_rand(0, 1) == 1 ? -1 : 1);
$font_size = 12;
$font = "/font/times_new_yorker.ttf";
$img = imagecreatefrompng($background);
$color = imagecolorallocate($img, 255, 255, 255);
//imagestring($img, 20, 30, 20, $code, $color);
imagettftext($img, $font_size, $angle, 5, 5, $color, $font, $code);
header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);