Php image processing

Source: Internet
Author: User
Php image processing

  1. Header ("content-type: image/jpeg ");
  2. /* 1. simple image output */
  3. $ Im = imagecreate (60, 40 );
  4. $ Pink = imagecolorallocate ($ im, 35, 25,220 );
  5. Imagejpeg ($ im );
  6. // Imagestring ($ im, 16,200,200, "I LOVE YOU ",);
  7. /* 2. write the string to the image */
  8. // Load the image
  9. $ Me = imagecreatefromjpeg (".../../images/3.jpg ");
  10. // Set the font color
  11. $ Text_color = imagecolorallocate ($ me, 255, 84, 0 );
  12. // Set the font position
  13. $ Font = "C: \ Windows \ Fonts \ simkai. ttf ";
  14. // String to be written
  15. $ Str = iconv ('gbk', "UTF-8", "php development ...");
  16. // Write the string to the image
  17. Imagettftext ($ me, 20, 0, 50, 50, $ text_color, $ font, $ str );
  18. // Output image
  19. Imagejpeg ($ me );
  20. // Release resources
  21. Imagedestroy ($ me );


  1. Session_start ();
  2. Header ("content-type: image/jpeg ");
  3. // Verification code
  4. // Image width
  5. $ Image_width = 65;
  6. // Image height
  7. $ Image_height = 45;
  8. // Seed the random number.
  9. // Srand (microtime () * 1000 );
  10. For ($ I = 0; $ I <6; $ I ++ ){
  11. $ New_str. = dechex (rand (0,100 ));
  12. }
  13. $ _ SESSION [code] = $ new_str;
  14. $ Image = imagecreate ($ image_width, $ image_height );
  15. Imagecolorallocate ($ image, rand (0,255), rand (0,255), rand (0,255 ));
  16. For ($ I = 0; $ I $ Font = mt_rand (3, 8); // Generate random font size
  17. $ X = mt_rand (3,10) + $ image_width * $ I/4;
  18. $ Y = mt_rand (3, $ image_height/4 );
  19. $ Color = imagecolorallocate ($ image, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 ));
  20. Imagestring ($ image, $ font, $ x, $ y, $ _ SESSION [code] [$ I], $ color );
  21. }
  22. Imagepng ($ image );
  23. Imagedestroy ($ image );


Image Processing, php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.