How to change the size of PHP captcha font

Source: Internet
Author: User
How to change the size of PHP captcha font



[color= #0000FF] This verification code picture shows the number is too small, how to change the size of the font in the following code, the number becomes larger [/color]
Generate a Captcha picture
Header ("Content-type:image/png");
$rand = "";
for ($i =0; $i <4; $i + +) {
$rand. =dechex (rand (0,15));
}

$im = Imagecreate (100,50); Make picture background size

$black = Imagecolorallocate ($im, 0,0,0); Set of three Colors
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
for ($i =0; $i <3; $i + +) {
$te =imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
}
Imagefill ($im, 0,0, $gray); Using area Fill method, set (0,0)

while (($rand =rand ()%100000) <10000);
Drawing a four-bit integer verification code into a picture
$_session[' rand ']= $rand;
Imagestring ($im, 5, $rand, $te);
Use the col color to draw the string s to the x, y coordinates of the image represented by the image (0, 0 in the upper-left corner).
If the font is 1,2,3,4 or 5, use the built-in font

for ($i =0; $i <200; $i + +)//Add interfering pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%100, Rand ()%50, $randcolor);
}
Imageline ($im, 0,rand (0,100), 100,rand (0,15), $randcolor);
Imageline ($im, 0,rand (0,100), 100,rand (0,15), $randcolor);
Imageline ($im, 0,rand (0,100), 100,rand (0,15), $randcolor);
Imagepng ($im);
Imagedestroy ($im);

?>

------to solve the idea----------------------
Imagestring ($im, 5, 1-5, $rand, $te); This function uses the built-in font, which is a range of. can only be replaced by the Imagettftext () function.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.