General > Support

Larger Font size for Captcha

(1/2) > >>

shwekhaw:
We have been getting increasing amount of spam bots recently so we have to put up Captcha. But the problem is real visitors are having trouble reading small fonts. I looked at captcha.php in libs folder. ImageString function has font size 5 as largest limit which is not large enough. I tried using imagettftext function and it does not work (don't know why. according to phpinfo, freetype library is enabled). Is there work around this to make the security code string larger (like using a function to enlarge the whole image?)

faf:
What do you mean by "freetype library"? imagettftext function is a part of GD library. You'd better provide the appropriate parts of your phpinfo() output.

And how did you used imagettftext function? Show us the code.

As for the zooming an image. Personally I think that it's a terrible idea. However, have you tried to search in the PHP documentation? What about this function?

shwekhaw:
Quote from php.net on imagettftext

--- Quote ---Note:
This function requires both the GD library and the ยป FreeType library.
--- End quote ---

Here is phpinfo
GD Support   enabled
GD Version   bundled (2.0.34 compatible)
FreeType Support   enabled
FreeType Linkage   with freetype
FreeType Version   2.3.11
T1Lib Support   enabled
GIF Read Support   enabled
GIF Create Support   enabled
JPEG Support   enabled
libJPEG Version   6b
PNG Support   enabled
libPNG Version   1.2.39
WBMP Support   enabled
XPM Support   enabled
XBM Support   enabled

Here is how I modify the code.


--- Code: ---
        $font = 'arial.ttf';
//     ImageString($image, 5, 30, 4, $security_code, $white);
imagettftext($image, 20, 0, 10, 20, $white, $font, $security_code);

--- End code ---

I will try imagecopyresampled function.

shwekhaw:
I made it work with imagecopyresampled function. Text looks little rough like zoom in effect. But it is readable.

faf:
Talking about imagettftext function. I don't know what you meant by "does not work", since you haven't provided any messages from error logs and haven't described any symptoms.

But I suspect that your arial.ttf file is either inaccessible (maybe you should have used the full path) or broken. (BTW, don't forget that fonts should be used according to their licenses...)

Navigation

[0] Message Index

[#] Next page

Go to full version