<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[虫虫的blog  SINCE2004]]></title> 
<link>http://www.zhenghe.biz/index.php</link> 
<description><![CDATA[人生幻灯片  -   前半生(身)，不要怕；后半生(身)，不要悔！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[虫虫的blog  SINCE2004]]></copyright>
<item>
<link>http://www.zhenghe.biz/read.php/.htm</link>
<title><![CDATA[php给上传图片加水印]]></title> 
<author>网络毛毛虫 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[技术文章]]></category>
<pubDate>Fri, 17 Dec 2004 13:33:02 +0000</pubDate> 
<guid>http://www.zhenghe.biz/read.php/.htm</guid> 
<description>
<![CDATA[ 
	$uptypes=array('image/jpg','image/jpeg','image/pjpeg','image/gif');//上传图片文件类型列表<br />$wFile=&quot;a.jpg&quot;;//取得文件路径<br />$waterimg=&quot;hq.gif&quot;;//水印图片路径<br />if(in_array($wFile['type'], $uptypes))<br />&#123;//检查文件类型，若上传的文件为jpg或gif图片则加水印<br />   if(strstr($wFile['type'],&quot;jp&quot;))&#123; //若上传图片类型为jpg,pjpeg,jpeg，则用imagecreatefromjpeg读取目标文件<br />    $im = imageCreatefromjpeg($wFile);<br /> $wfilew=imagesx($im);//取得图片的宽<br /> $wfileh=imagesy($im);//取得图片的高<br />   &#125;else&#123;//否则若上传图片类型为gif，则用imagecreatefromgif读取目标文件<br />    $im = imageCreatefromgif($wFile);<br /> $wfilew=imagesx($im);//取得图片的宽<br /> $wfileh=imagesy($im);//取得图片的高<br /> &#125;<br />   //设定混合模式<br />    imagealphablending($im, true);<br />    //读取水印文件<br />    $im2 = imagecreatefromgif($waterimg);//若水印图片为jpg，则此去可改为$im2 = imagecreatefromjpeg($waterimg)<br /> $waterw=imagesx($im2);//取得水印图片的宽<br /> $waterh=imagesy($im2);//取得水印图片的高<br />    //随机放水印到图片中<br /> $randval = rand(0,9);//在0-9之间产生随机数<br /> if($randval==0||$randval==3||$randval==2||$randval==8||$randval==7)&#123;//此处还可完善放更多位置<br /> $wimgx=5;$wimgy=5;//放左上角<br /> &#125;else&#123;<br /> $wimgx=$wfilew-5-$waterw;$wimgy=$wfileh-5-$waterh;//放右上角<br /> &#125;<br /> //拷贝水印到目标文件<br /> imagecopy($im, $im2, $wimgx, $wimgy, 0, 0, $waterw,$waterh);<br />    <br /> //输出图片<br />   if(strstr($wFile['type'],&quot;jp&quot;))&#123; //同上<br /> imagejpeg($im,$wFile);<br /> &#125;else&#123;<br /> imagegif($im,$wFile);<br /> &#125;<br />    imagedestroy($im);<br />    imagedestroy($im2);<br />&#125;<br />
]]>
</description>
</item><item>
<link>http://www.zhenghe.biz/read.php/.htm#blogcomment</link>
<title><![CDATA[[评论] php给上传图片加水印]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhenghe.biz/read.php/.htm#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>