Home  >  Article  >  Backend Development  >  Simple example of php image processing function

Simple example of php image processing function

WBOY
WBOYOriginal
2016-07-25 08:51:511027browse
  1. //header('Content-Type: text/html;charset=utf-8');

  2. //Image processing
  3. //1 Set MIME type output type text/html defaults to the web page type and does not need to be written
  4. header('Content-Type:image/png;');
  5. $width = 400;
  6. $height = 400;
  7. //2 Create an image area width and height
  8. $img = imagecreatetruecolor($width,$height);
  9. //Assign color handle to the image, red and green
  10. $blue = imagecolorallocate($img,0,102,255);
  11. //Fill color resource handle x-axis y-axis color
  12. imagefill($img,0,0,$blue);
  13. //Continue to create colors
  14. $while = imagecolorallocate($img,255,255,255);
  15. //Draw a line handle x start y start x end y end color
  16. imageline($img,60,90,90,60,$while);
  17. //Print image information
  18. getimagesize($img);

  19. //Draw text handle font size x-axis Y-axis content color

  20. imagestring($img,5,0,0,'wwwww',$while);
  21. //Load image list() This function is good
  22. imagecreatefrompng('22.png');
  23. / /The original image is copied from the new sample to the new image
  24. //New image handle original image handle new image xy original image xy new image length plateau original image length height
  25. imagecopyresampled($img,$yuan,40,40,0,0,$ _width,$_height,$width,$height);
  26. //Output image
  27. imagepng($img);
  28. //Destroy handle
  29. imagedestroy($img);
  30. ?>

Copy code


Statement:
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