| 域名空间 下载中心 社区论坛 信息公告 my小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
给图片添加水印(支持中文)并生成缩略图http://www.iyit.net 日期:2006-10-6 15:38:48 来源:iyit.net收集 点击: |
// **************************************** // // 功能:给图片添加水印(支持中文)并生成缩略图 // 参数: $srcfile 图片文件名 // $dstfile 另存图片文件名 // $markwords 水印文字内容 // $markimage 水印图片地址 // $dstw 图片保存宽度 // $dsth 图片保存高度 // $rate 图片保存品质 // **************************************** // function makethumb($srcfile,$dstfile,$dstw,$dsth,$rate=100,$markwords=null,$markimage=null) { $data = getimagesize($srcfile); switch($data[2]) { case 1: $im=@imagecreatefromgif($srcfile); break; case 2: $im=@imagecreatefromjpeg($srcfile); break; case 3: $im=@imagecreatefrompng($srcfile); break; } if(!$im) return false; $srcw=imagesx($im); $srch=imagesy($im); $dstx=0; $dsty=0; if ($srcw*$dsth>$srch*$dstw) { $fdsth = round($srch*$dstw/$srcw); $dsty = floor(($dsth-$fdsth)/2); $fdstw = $dstw; } else { $fdstw = round($srcw*$dsth/$srch); $dstx = floor(($dstw-$fdstw)/2); $fdsth = $dsth; } $ni=imagecreatetruecolor($dstw,$dsth); $dstx=($dstx<0)?0:$dstx; $dsty=($dstx<0)?0:$dsty; $dstx=($dstx>($dstw/2))?floor($dstw/2):$dstx; $dsty=($dsty>($dsth/2))?floor($dsth/s):$dsty; $white = imagecolorallocate($ni,255,255,255); $black = imagecolorallocate($ni,0,0,0); imagefilledrectangle($ni,0,0,$dstw,$dsth,$white);// 填充背景色 imagecopyresized($ni,$im,$dstx,$dsty,0,0,$fdstw,$fdsth,$srcw,$srch); // 生成水印 if($markwords!=null) { $markwords=iconv("gb2312","utf-8",$markwords); //转换文字编码 imagettftext($ni,9,0,10,15,$white,"simhei.ttf",$markwords); //imagettftext(int im,int size,int angle,int x,int y,int col,string fontfile,string text): //本函数将 ttf (truetype fonts) 字型文字写入图片。 //参数: size 为字形的尺寸; // angle 为字型的角度,顺时针计算,0 度为水平(由左到右),90 度则为由下到上的文字; // x,y 二参数为文字的坐标值 (原点为左上角); // col 为字的颜色; // fontfile 为字型文件名称; // text 是字符串内容。 } elseif($markimage!=null) { $wimage_data = getimagesize($markimage); switch($wimage_data[2]) { case 1: $wimage=@imagecreatefromgif($markimage); break; case 2: $wimage=@imagecreatefromjpeg($markimage); break; case 3: $wimage=@imagecreatefrompng($markimage); break; } imagecopy($ni,$wimage,0,0,0,0,88,31); imagedestroy($wimage); } imagejpeg($ni,$dstfile,$rate); imagedestroy($im); imagedestroy($ni); //结束图形,释放内存空间 } 编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:表格对齐问题 下一篇:如何判断用户浏览器异常退出 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 相关文章 | ||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||