I'm trying to make a captcha in php. This is my code:
$amountChars = 5;
$randString = substr(md5(uniqid()), 0, $amountChars);
$img = imagecreatfromjpeg("noise.jpg");
imageantialias($img, true);
$x = 20;
$y = 35;
$deltaX = 40;
for($i = 0; $i < $amountChars; $i++){
$size = rand(18, 28);
$r = rand(0,152);
$g = rand(0,152);
$b = rand(0,152);
$color = imagecolorallocate($img, $r, $g, $b);
$angle = -30 + rand(0, 60);
imagettftext($img, $size, $angle, $x, $y, $color, "Blokletters-Balpen.ttf", $randString{$i});
$x += $deltaX;
}
header("Content-Type: image/png");
imagePNG($img);
Problem is, that it does not work. I'm searching a mistake over an hour, but unsuccessfully.