Why not just 'recaptcha'? It's all done for you - and they're secure and also have a really really simple API that you can use.
I would suggest recaptcha... Otherwise, you will need to write a script that uses GD and freetype... A lot of forums use this method
Well if you are trying to load a PNG the code is: $pngHandle = imageloadfrompng('file'); PHP: Yes reCaptcha is a much better solution though.