php graphics image processing

WBOY
Release: 2016-07-25 08:42:43
Original
1023 people have browsed it
  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 Into 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. //The position of the set font
  13. $font = "C:WindowsFontssimkai.ttf";
  14. //The string to be written
  15. $str = iconv('GBK',"UTF-8", "php development...");
  16. //Write the string into the image
  17. imagettftext($me,20,0,50,50, $text_color,$font, $str);
  18. //Output the image
  19. imagejpeg($me);
  20. //Release resources
  21. imagedestroy($me);
Copy code

  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. //Set the random number seed
  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
  17. $font = mt_rand(3, 8);//Generate random font size
  18. $x = mt_rand(3 ,10)+$image_width*$i/4;
  19. $y = mt_rand(3,$image_height/4);
  20. $color = imagecolorallocate($image,mt_rand(0, 255), mt_rand(0, 255), mt_rand (0, 255));
  21. imagestring($image, $font, $x, $y,$_SESSION[code][$i], $color);
  22. }
  23. imagepng($image);
  24. imagedestroy($image );
Copy code

image processing, php


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!