Проблем с captcha

DownFall

Registered
Изпозлвам за основа този урок - http://web-tourist.net/login/login/view.php?st=893
Моднах малко кода и в мометна изглежда така:

Код:
    public final static function captchaGenerate()
    {
        header('Content-Type: image/jpeg');
        $width = 120;
        $height = 30;
        $font_size = $height * 0.75;
        $image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');

        $background_color = imagecolorallocate($image, 0, 0, 0);
        $text_color = imagecolorallocate($image, 255, 255, 255);
        $noise_color = imagecolorallocate($image, 204, 153, 102);

        for($i=0; $i < ($width * $height) / 4; $i++)
            imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);

        /*
        for($i=0; $i < ($width * $height) / 150; $i++)
            imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
        */

        $textbox = imagettfbbox($font_size, 0, self::$captchaFont, self::$captchaCode);
        
        $x = ($width - $textbox[4]) / 2;
        $y = ($height - $textbox[5]) / 2;
        
        imagettftext($image, $font_size, 0, $x, $y, $text_color, self::$captchaFont, self::$captchaCode);
        imagejpeg($image);
        imagedestroy($image);
    }

Проблема е, че не всеки път извежда цифрите в картинката.. При 10-тина зареждания, грубо около 2-3 са без цифри в картинката, докато точките например си излизат всеки път.

Защо се получава така и как може да оправя проблема?

Благодаря предварително.
 

Back
Горе