CAPTCHA Image Generation Part 2

July 19th, 2007
No Gravatar

A quick morning hack - I added some random lines to try and confuse the automated processes. Its probably still not very secure but it’s a start!

Add the following code below the last imagettftext() line.

$image_info = getimagesize("badge4.png");
$i = 1;
while ($i <= 10) {
$random_line_colour = ImageColorAllocate($base_image, rand(0,255), rand(0,255), rand(0,255));
imageline($base_image,rand(10,$image_info[0]), rand(10,$image_info[1]), rand(10,$image_info[0]), rand(10,$image_info[1]),$random_line_colour);
$i++;
}

It will end up similiar to this

untitled1.PNG

Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo


Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the PHP category.

Leave a Reply