26 April 2007

About CAPTCHA

Complete name: "Completely Automated Public Turing test to tell Computers and Humans Apart"

It is similar to Image-recognition or a different way to implement AI.

With reference to develop this with PHP, it required to have support for creating images on the fly with required content on it like GD Library.

PHP Sample Code:

Header("Content-type: image/png");
$string = $_GET['code'];
$im = imagecreatefromgif("images/imageback.gif"); //background image
$orange = ImageColorAllocate($im, 0, 150, 225);
$px = (imagesx($im)-9*strlen($string))/2;
// $font = imageloadfont("04b.gdf");
imagestring($im,6,$px,3,$string,$orange);
imagepng($im);
//ImageDestroy($im);
?>

No comments: