Home  >  Article  >  Backend Development  >  PHP uploads images and sets transparent image watermark effects

PHP uploads images and sets transparent image watermark effects

WBOY
WBOYOriginal
2016-07-25 08:51:50996browse
  1. $im = imagecreatefromjpeg($_file["upload"]["tmp_name"]); //Picture

  2. $watermark = imagecreatefrompng("Smiley.png"); //Watermark image Path
  3. $im_x = imagesx($im);
  4. $im_y = imagesy($im);
  5. $w_x = imagesx($watermark);
  6. $w_y = imagesy($watermark);
  7. imagecopy($im,$watermark, $im_x-$w_x,$im_y-$w_y,0,0,$w_x,$w_y);
  8. imagejpeg($im); //You can add a path to save the watermarked image

  9. < p>//Use type to determine the image type
  10. //switch($_file["upload"]["type"])
  11. //case:1
  12. //Other gd library functions
  13. //imagejpeg() corresponds to jpeg
  14. //imagegif() corresponds to gif
  15. //imagepng() corresponds to png
  16. imagedestroy($im);

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