Home >Backend Development >PHP Tutorial >PHP generates background color image verification code_PHP tutorial

PHP generates background color image verification code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:46:01914browse

After imagecreatetruecolor() creates a true color image,
It will not automatically use the first color registered by the imagecolorallocate() method as the background color, but must be filled with imagefill()


//Set color

$bg = imagecolorallocate($im, 240, 240, 0);//Set the background color
imagefill($im,0,0,$bg);//Load background color
$te = imagecolorallocate($im, 0, 0, 0);//String color
//Add string to image
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 a black image of the specified size.

Depending on whether the function is defined or not in your PHP and GD versions. For PHP 4.0.6 through 4.1.x this function is always present


For more details, please check: php tutorialer/24/php-imagecreatetruecolor.htm">http://www.bKjia.c0m/phper/24/php-imagecreatetruecolor.htm

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632973.htmlTechArticleAfter imagecreatetruecolor() creates a true color image, it will not automatically register the first one in the imagecolorallocate() method The color is used as the background color, and imagefill() must be used to fill//set...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn