If you want to use the PHP drawing function, first of all to enable the function of this module. Just remove the php_gd2.dll in front of the php.ini.
Start drawing below:
Copy CodeThe code is as follows:
Session_Start ();
Generate a Captcha picture
Header ("Content-type:image/png");
$im = Imagecreate (44,18); Draw a picture that specifies a wide height
$back = Imagecolorallocate ($im, 245,245,245); Define background color
Imagefill ($im, 0,0, $back); Fill the background color into the picture you just drew
$vcodes = "";
Srand (Double) microtime () *1000000);
Generate 4-bit numbers
for ($i =0; $i <4; $i + +) {
$font = Imagecolorallocate ($im, Rand (100,255), Rand (0,100), Rand (100,255)); Generate Random Colors
$authnum =rand (1,9);
$vcodes. = $authnum;
Imagestring ($im, 5, $i *10, 1, $authnum, $font);
}
$_session[' vcode '] = $vcodes;
for ($i =0; $i <100; $i + +)//Add interfering pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor); Image Point function
}
Imagepng ($im);
Imagedestroy ($im);
?>
Basically this is the way to achieve, in fact, if the picture to water printing is nothing more than to write in the picture, the principle is similar.
Use the place directly
Fill in the name of this PHP file and you can use it.
http://www.bkjia.com/PHPjc/322029.html www.bkjia.com true http://www.bkjia.com/PHPjc/322029.html techarticle If you want to use the PHP drawing function, first of all to enable the function of this module. Just remove the php_gd2.dll in front of the php.ini. Here's how to start drawing: Copy code code as follows ...