Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Function to bend/warp an image

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?

like image 781
Sherri Avatar asked Sep 06 '25 03:09

Sherri


1 Answers

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! :-)

like image 165
André Hoffmann Avatar answered Sep 07 '25 22:09

André Hoffmann