All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET Remoting体系结构(八)
对PHP程序中的常见漏洞进行攻击_[PHP教程]
Login控件在UpdatePanel内当验证用户信息成功后出现页面刷新的解决办法_.net资料_编程技术
XSL学习心得-制作图像超链接_[XML教程]
一个C#高级编程中的事件,DEMO,实例_.net资料_编程技术
.net读取扩展名为xml的资源文件_[Asp.Net教程]
SQL时间函数,值得收藏_[SQL Server教程]
SQL,Server,2005数据库产品线的扩展_[SQL,Server教程]
如何用C#写一个简单的Login窗口_[Asp.Net教程]
Cake:让PHP也跑在铁轨上_php资料_编程技术
Reading number is top 10 pictures
A cat have life principles
Kim jong il's mistress, national beauty JinYuJi actor1
深圳的风光
The money of more than 100 countries and regions16
NeedWallpaper5
Azusa Yamamoto1
到底是谁撞谁呀?
美女当网吧管理员的悲剧
Absolutely shocked. National geographic 50 animal photographys7
Look for from human art net, is good1
Download software ranking
Love the forty days
c#程序设计案例教程
Adobe Flash Player(IE) 10.0.32.18 浏览器专用的FLASH插件
Wild things 2
Rio big adventure
Prostitutes diary
The Bermuda triangle3
Boxer vs Yellow3
Tram sex maniac 2 (H) rar bag8
Dance with duck(male prostitution)
归海一刀 published in(发表于) 2014/2/17 7:30:16 Edit(编辑)
PHP实例程序:实现给上传图片加水印图案的做法_[PHP教程]

PHP实例程序:实现给上传图片加水印图案的做法_[PHP教程]

PHP实例程序:实现给上传图片加水印图案的做法_[PHP教程]








上传图片






 












路径:












  
















 






 






 








网页教学网webjx.com
if(_POST['action']=='doup')
{
uptypes=array('image/jpg','image/jpeg','image/pjpeg','image/gif');//上传图片文件类型列表
wFile=_FILES['upfile'];//取得文件路径
waterimg="water.gif";//水印图片路径
//print_r(wFile);
if(in_array(wFile['type'], uptypes))
{//检查文件类型,若上传的文件为jpg或gif图片则加水印
if(strstr(wFile['type'],"jp"))
{ //若上传图片类型为jpg,pjpeg,jpeg,则用imagecreatefromjpeg读取目标文件
im = imageCreatefromjpeg(wFile['tmp_name']);
wfilew=imagesx(im);//取得图片的宽
wfileh=imagesy(im);//取得图片的高
}
else
{//否则若上传图片类型为gif,则用imagecreatefromgif读取目标文件
im = imageCreatefromgif(wFile['tmp_name']);
wfilew=imagesx(im);//取得图片的宽
wfileh=imagesy(im);//取得图片的高
}
//设定混合模式
imagealphablending(im, true);
//读取水印文件
im2 = imagecreatefrompng(waterimg);//若水印图片为jpg,则此去可改为im2 = imagecreatefromjpeg(waterimg)
//white = imagecolorallocate(im2, 255, 255, 255);
// imagecolortransparent(im2,white); //设透明色,这两句可不要
waterw=imagesx(im2);//取得水印图片的宽
waterh=imagesy(im2);//取得水印图片的高
//随机放水印到图片中
randval = rand(0,9);//在0-9之间产生随机数
if(randval==0||randval==3||randval==2||randval==8||randval==7){//此处还可完善放更多位置
wimgx=5;wimgy=5;//放左上角
}else{
wimgx=wfilew-5-waterw;wimgy=wfileh-5-waterh;//放右上角
}
//拷贝水印到目标文件
imagecopy(im, im2, wimgx, wimgy, 0, 0, waterw,waterh);

//输出图片
if(strstr(wFile['type'],"jp")){ //同上
imagejpeg(im,wFile['tmp_name']);
}else{
imagegif(im,wFile['tmp_name']);
}
imagedestroy(im);
imagedestroy(im2);
copy(wFile['tmp_name'],wFile['name']); //上传
}
else echo "图片不符合!!";
}
?>







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.