-
- Header ("content-type: image/jpeg ");
-
- /* 1. simple image output */
- $ Im = imagecreate (60, 40 );
- $ Pink = imagecolorallocate ($ im, 35, 25,220 );
- Imagejpeg ($ im );
-
- // Imagestring ($ im, 16,200,200, "I LOVE YOU ",);
-
- /* 2. write the string to the image */
- // Load the image
- $ Me = imagecreatefromjpeg (".../../images/3.jpg ");
- // Set the font color
- $ Text_color = imagecolorallocate ($ me, 255, 84, 0 );
- // Set the font position
- $ Font = "C: \ Windows \ Fonts \ simkai. ttf ";
- // String to be written
- $ Str = iconv ('gbk', "UTF-8", "php development ...");
- // Write the string to the image
- Imagettftext ($ me, 20, 0, 50, 50, $ text_color, $ font, $ str );
- // Output image
- Imagejpeg ($ me );
- // Release resources
- Imagedestroy ($ me );
- Session_start ();
- Header ("content-type: image/jpeg ");
- // Verification code
- // Image width
- $ Image_width = 65;
- // Image height
- $ Image_height = 45;
- // Seed the random number.
- // Srand (microtime () * 1000 );
-
- For ($ I = 0; $ I <6; $ I ++ ){
- $ New_str. = dechex (rand (0,100 ));
- }
- $ _ SESSION [code] = $ new_str;
-
- $ Image = imagecreate ($ image_width, $ image_height );
- Imagecolorallocate ($ image, rand (0,255), rand (0,255), rand (0,255 ));
-
- For ($ I = 0; $ I $ Font = mt_rand (3, 8); // Generate random font size
- $ X = mt_rand (3,10) + $ image_width * $ I/4;
- $ Y = mt_rand (3, $ image_height/4 );
- $ Color = imagecolorallocate ($ image, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 ));
- Imagestring ($ image, $ font, $ x, $ y, $ _ SESSION [code] [$ I], $ color );
- }
- Imagepng ($ image );
- Imagedestroy ($ image );
|