|
<?
Session_start ();
// Generate a random number
For ($ I = 0; $ I <4; $ I ++ ){
$ Rand. = dechex (rand (1, 15 ));
}
$ _ SESSION ['checkpic '] = $ rand;
$ Im = imagecreatetruecolor (, 30); // canvas to create a true color image
// Set the color
$ Bg = imagecolorallocate ($ im, 0, 0); // red, green, and blue background color
$ Te = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255); // font color
// Draw lines
For ($ I = 0; $ I <3; $ I ++ ){
$ Te2 = imagecolorallocate ($ instant, rand (0,255), rand (0,255), rand (0,255 ));
Imageline ($ im, rand (0,100), 0, rand (0,100), 30, $ te2); // coordinates (x1, y1) to coordinates (x2, y2)
}
// Draw Point
For ($ I = 0; I I <200; $ I ++ ){
Imagesetpixel ($ im, rand () % 100, rand () % 30, $ te2 );
}
// Output Chinese characters
$ Str = iconv ("gbk", "UTF-8", "Happy New Year! "); // Determine the Chinese text to draw
Imagettftext ($ im, 12, 3, 20, 20, $ te, 'msyhbd. Ttf', 'Chinese en ');
// Write the string in the upper left corner of the image
// Imagestring ($ im, 5, rand (0, 50), rand (0, 15), $ rand, $ te );
// Output image
Header ("Content-type: image/jpeg"); // file type
Imagejpeg ($ im );
?> |