Samuli Kauranne - 2014-04-16

Hi,

I really like your library. It's simple and elegantly coded, does just what it should very fast. In many ways superior to the solution I had before.

However, I encountered a minor bug which caused every now and then one of the letters to appear as a white rectangle. I managed to locate the source of the bug: apparently php5 imagerotate() function does not like to be told to rotate the image 0 degrees, so whenever the rand(-15,15) given as rotation produces a zero, the imagerotate() function returns a blank image.

My solution was to add the following line to generateValidationImage() method before the call to the imagerotate(). I'm then using the $rotation as the rotation argument.
do $rotation = rand(-15,15); while($rotation == 0);

If you would specifically wish to allow for the zero rotation case, I guess you could also just randomize the rotation and then decide with an if clause, whether you pass the image as it is to the ImageCopy() function (case 0 degrees) or you put it through the imagerotate() first.

Best regards and thanks for sharing your work!