If you want to use PHP's drawing function, you first need to enable the function of this module. Just remove the php_gd2.dll in front of the php.ini.
Start drawing below:
Copy Code code as follows:
<?php
Session_Start ();
Generate Captcha Picture
Header ("Content-type:image/png");
$im = Imagecreate (44,18); Draw a picture that specifies the width and 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-digit 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 interference pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor); The function of the element point of portrait
}
Imagepng ($im);
Imagedestroy ($im);
?>
Basically is the way to achieve, in fact, if you give pictures of water printing is simply to write in the picture, the principle is similar.
Use of the place directly
Fill in the name of this PHP file, you can use the.