PHP Generate background color picture Verification Code _php tutorial

Source: Internet
Author: User
Tags image identifier set background
Imagecreatetruecolor () After creating a true color image,
The first color that is registered with the Imagecolorallocate () method is not automatically used as the background color, but must be filled with imagefill ().


Set color

$BG = Imagecolorallocate ($im, 240, 240, 0);//Set Background color
Imagefill ($im, 0,0, $BG);//Load background color
$te = imagecolorallocate ($im, 0, 0, 0);//String color
Add a string to the picture
Imagestring ($im, Rand (3,6), Rand (5,60), Rand (5,15), $rand, $te);
Output picture
Header ("Content-type:image/jpeg");
Imagejpeg ($im);

Imagecreatetruecolor () returns an image identifier representing the black image of the specified size.

According to your PHP and GD version of the function definition or not. For PHP 4.0.6 through 4.1.x This function always exists


For more details please see: PHP tutorial Er/24/php-imagecreatetruecolor.htm ">http://www.bkjia.c0m/phper/24/php-imagecreatetruecolor.htm

http://www.bkjia.com/PHPjc/632973.html www.bkjia.com true http://www.bkjia.com/PHPjc/632973.html techarticle Imagecreatetruecolor () After creating a true color image, the first color of the Imagecolorallocate () method is not automatically registered as the background color, but must be filled/set with Imagefill () ...

  • 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.