File size: 899B
<?php
$width = 45;
$height = 34;
$font = 'verdana.ttf';
$f_size = 16;
$bg_color = array(240, 240, 240);
$chars = 'ABCDEFGHKMNPQRSTUVWXYZ23456789';
session_start();
putenv('GDFONTPATH=' . realpath('.'));
$img = imagecreatetruecolor($width, $height);
$bkgr = imagecolorallocate($img, $bg_color[0], $bg_color[1], $bg_color[2]);
imagefilledrectangle($img, 0, 0, $width, $height, $bkgr);
$code = '';
for($i = 0; $i < 2; $i++)
{
$code .= $chr = $chars[mt_rand(0, strlen($chars)-1)];
imagettftext($img, $f_size, mt_rand(-25,25), 5+$i*(4/3*$f_size+2), mt_rand(4/3*$f_size, $height-(4/3*$f_size)/2), imagecolorallocate($img, mt_rand(0,192), mt_rand(0,192), mt_rand(0,192)), $font, $chr);
}
$_SESSION['random_txt'] = md5($code);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>