views:

589

answers:

1

I'm working with my simple PHP captcha algorithm (http://www.source.ofitall.com/devel/captcha.php) and I have been struggling to try and adjust it to be the more attractive and easier to read, Google style captcha.

Does anyone know of a function that will take in a GD image reference and bend/warp it, Google style?

+2  A: 

If you can use ImageMagick on your server you might want to give this a try:

  convert koala.gif -background Blue  -wave 10x64  wave.jpg

UPDATE:

If you aren't using some library you will obviously have to write your own implementation.

Here are some suggestions where you can find useful informations on that:

  • If you are more of a hands on guy have a look at this freely available Java implementation of a SwimFilter or WarpFilter that can be downloaded here

  • Then there's an explanation of the 2-spline mash warping algorithm that might do what you want here.

  • Here's a good overview over algorithms that might suit your needs(Microsoft doc file).

You should be aware though that this isn't something that's easily implemented. But if you are interested in the topic and really really have to live withouth ImageMagick than that's your only chance(as far as I know).

And then there's also GD's bad performance..

Good luck! :-)

André Hoffmann
I like that, and I have used ImageMagick in other projects. However this Captcha script is intended to be a drop in php script that ppl can use and I don't want to make ImageMagick a requirement. I've seen algorithms that shift the pixels in an image using a sine wave... I was wondering if there was a function for that.
Sherri
Every hoster I've tried so far supported ImageMagick. I understand your concern, but I think the performance vs. least possible requirements tradeoff is just too big. I urge you to think about if you really need to use GD for this.
André Hoffmann
Yes, while ImageMagick is on nearly all hosts, I'm trying to distribute this CAPTCHA script as a self contained PHP only function. So while your solution is an obvious and simple one, I'm looking for a GD function.
Sherri
See my updated comment for alternatives to ImageMagick.
André Hoffmann