Home  >  Article  >  Backend Development  >  php上传图片并打上透明水印的代码

php上传图片并打上透明水印的代码

WBOY
WBOYOriginal
2016-07-25 09:03:471095browse
  1. $im = imagecreatefromjpeg($_file["upload"]["tmp_name"]); //你要打水例子的图片
  2. $watermark = imagecreatefrompng("Smiley.png"); //水印图的路径
  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); //可加上路径以保存有水印的图
  9. //可以利用type判断下图片类型
  10. //switch($_file["upload"]["type"])
  11. //case:1
  12. //然后用不同的函数
  13. //imagejpeg()对应jpeg
  14. //imagegif()对应gif
  15. //imagepng()对应png
  16. imagedestroy($im);
复制代码


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