Home  >  Article  >  Backend Development  >  关于给图片加水印,该如何处理

关于给图片加水印,该如何处理

WBOY
WBOYOriginal
2016-06-13 11:21:40862browse

关于给图片加水印
我写了一个采集程序 采集网上的图片 采集回来的是一堆乱码字符
header("Content-type:image/jpeg;charset=utf-8");之后能显示正常图片
现在我想给图片加上水印
我是把采集的图片直接保存到目录上  然后再加载按下面方式处理
$fp = @imagecreatefromjpeg(图片路径);
$wp = @imagecreatefrompng(水印路径);
$res = imagecopy($fp,$wp,0,0, 0, 0,120,180);
imagejpeg($fp);
现在我想不保存到目录 直接加上水印在页面上显示该如何处理 请大家指教一下 谢谢


------解决方案--------------------
不是有 imagecreatefromstring 吗?
$fp = imagecreatefromstring(file_get_contents('http://avatar.profile.csdn.net/9/D/6/1_dream1206.jpg'));<br />$wp = imagecreatefromstring(file_get_contents('http://avatar.profile.csdn.net/1/5/6/1_gilper.jpg'));<br />imagecopymerge($fp,$wp,0,0, 0, 0,120,180, 50);<br />imagepng($fp);
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