Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
I know I have a more advanced version of this script somewhere but can't find it so here's a more primitive one I built. You can save this as a php file, and then link to the php file as an image like <img src="thephpfile.php" />. It uses the GD Library to create an image with random characters of random colors. I used to have alternating backgrounds, as well as titled letters. This should probably help your problem somewhat though. Anyways, this script also sets a session variable 'imageVeriChars' to a hash of the letters that were on the image. That way when they submit the form, you can apply the md5 function to what they entered and compare it to what's in $_SESSION['imageVeriChars'].

Oh and './images/verificationimgbg.png' needs to be replaced with the path to a background .png image.

It'll take some fiddling to get to work, but it might be of some help to you.


PHP:
<?php 

$width = 80;
$height = 40;
$image = ImageCreate($width,$height);
$color = ImageColorAllocate($image,41,41,41);


srand((double)microtime()*1000000); 

$string = md5(rand(0,9999));

$string = substr($string,17,5);

$bg = imagecreatefrompng("./images/verificationimgbg.png");

imagesettile($image, $bg);

ImageFilledRectangle($image,0,0,$width, $height,IMG_COLOR_TILED);

$textcolor = ImageColorAllocate($image,153,153,153);

$xposition = rand(1,32);

$yposition = rand(1,19);

if(!$string) {
	die("String contained no value.");
}

ImageString($image, 8, $xposition, $yposition, $string, $textcolor);

session_start();



$_SESSION['imageVeriChars'] = md5($string);

if(!$_SESSION['imageVeriChars']) {
	die("Session not set.");
}

 


// send the image
header("content-type: image/png");
ImagePNG($image);
ImageDestroy($image);

?>


Note: This hasn't been tested it since I found it buried deep in my machine and I'm not sure how well if at all it'll work.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.