Before doing this, first take a look at the official documentation
Zend_captcha_image
The image adapter parses the generated character into an image and converts it into an image that is hard to be automatically decrypted. It requires» GD extension, which can be compiled using TrueType or FreeType. Currently, the image adapter can only generate PNG images.
Zend_captcha_image integrates zend_captcha_word and attaches the following methods:
Setexpiration ($ Expiration) And getexpiration () specify the maximum lifecycle of the CAPTCHA image that can be retained in the file system. It is generally longer than the session lifecycle. Each time a CAPTCHA object is called, spam runs once, and expired images are cleared. The expiration value is in seconds.
Setgcfreq ($ Gcfreq) And getgcfreg () Specify the frequency of garbage collection. Each1/$ GcfreqGarbage collection runs once (default value:100).
Setfont ($ Font) And getfont () Specify the font to use. It is the full path to the font file. If this value is not set, CAPTCHA throws an exception during generation. The font is required.
Setfontsize ($ Fsize) And getfontsize () Specify the font size, in pixels, used to generate CAPTCHA. The default value is 24px.
Setheight ($ Height) And getheight () Specify the height of the generated CAPTCHA image, in pixels. The default value is 50px.
Setwidth ($ Width) And getwidth () Specify the width of the generated CAPTCHA image, in pixels. The default value is 200px.
Setimgdir ($ Imgdir) And getimgdir () Specify the directory for storing CAPTCHA images. Default Value:"./Images/CAPTCHA/", Relative to the bootstrap script.
Setimgurl ($ Imgurl) And getimgurl () Specify the relative path of the CAPTCHA image used for the HTML markup language. Default Value:"/Images/CAPTCHA/".
Setsuffix ($ Suffix) And getsuffix () Specify the filename suffix. Default Value:". PNG". Note: Its changes do not affect the image type.
All the above options can be passed to the constructor as an option, as long as you remove'Set'Method prefix and change the first letter to lower case: for example"Suffix","Height","Imgurl".
General Usage
$ Font_dir = Realpath ( Dirname ( _ File __ ) . ' Http://www.cnblogs.com/www/font/simsun.ttc ' );
$ Im = New Zend_captcha_image ( Array (
' Font ' => $ Font_dir ,
' Fontsize ' => 14 ,
' Wordlen ' => 4 ,
' Height ' => 20 ,
' Width ' => 60
));
$ Im -> Generate ();
Return $ Im -> Getimgurl () . $ Im -> GETID () . $ Im -> Getsuffix ();
FAQs:
- Noise, too many interference lines, a little unclear
- The image content cannot be standardized.
- You cannot set the font curvature of an image.
Solution
Update tomorrow.