& Quot; functionverifyImg ($ width80, $ height30) {defines the canvas $ imgimagecreatetruecolor ($ width, $ height); defines the color $ whiteimagecolorallocate ($ img, 255,255,255 ); $ blackimagecolorallocate ($ img, 0); draw the canvas imagefilledrectangle ($ img, $ width-2, $ h... verification code php function
Function verifyImg ($ width = 80, $ height = 30) {// defines the canvas $ img = imagecreatetruecolor ($ width, $ height ); // define the color $ white = imagecolorallocate ($ img, 255,255,255); $ black = imagecolorallocate ($ img, 0, 0); // draw the canvas imagefilledrectangle ($ img, 1, 1, $ width-2, $ height-2, $ white); // write $ size = mt_rand (18, 22); $ angle = mt_rand (-3 ); $ x = mt_rand (2, 10); $ y = mt_rand (20, 28); $ fontfiles = '.. /font/simhei. ttf'; $ _ SESSION ['verify '] = $ str = randomStr (); imagettftext ($ img, $ size, $ angle, $ x, $ y, $ black, $ fontfiles, $ str); // add interference points for ($ I = 0; $ I <100; $ I ++) {$ x = mt_rand (1, $ width-1); $ y = mt_rand (1, $ height-1); $ red = mt_rand (1,150); $ green = mt_rand (1,150 ); $ blue = maid (1,150); $ color = imagecolorallocate ($ img, $ red, $ green, $ blue); imagesetpixel ($ img, $ x, $ y, $ color);} // generate the image header ("content-type: image/gif"); imagegif ($ img); imagedestroy ($ img );
Please help me to see what went wrong!
I have no clue!
I used it well before, and suddenly I couldn't use it!
The GD library is open!