阳江市网络问政平台登录,太原网站优化,域名备案接入商查询,广州市网站设计公司/**———————————————————-* 为图片添加水印———————————————————-* static public———————————————————-* param string $source 原文件名* param string $water 水印图片* param string $$savename 添加水印后的图片名…/**———————————————————-* 为图片添加水印———————————————————-* static public———————————————————-* param string $source 原文件名* param string $water 水印图片* param string $$savename 添加水印后的图片名* param string $alpha 水印的透明度———————————————————-* return string———————————————————-* throws ThinkExecption———————————————————-*/static public function water($source, $water, $savenamenull, $alpha80) {//检查文件是否存在if (!file_exists($source) || !file_exists($water))return false;//图片信息$sInfo self::getImageInfo($source);$wInfo self::getImageInfo($water);//如果图片小于水印图片不生成图片if ($sInfo[width] $wInfo[width] || $sInfo[height] $wInfo[height])return false;//建立图像$sCreateFun imagecreatefrom . $sInfo[type];$sImage $sCreateFun($source);$wCreateFun imagecreatefrom . $wInfo[type];$wImage $wCreateFun($water);//设定图像的混色模式imagealphablending($wImage, true);//图像位置,默认为右下角右对齐$posY $sInfo[height] – $wInfo[height];$posX $sInfo[width] – $wInfo[width];/* 为了保持PNG的透明效果 使用imagecopy 此处为修改过的*/imagecopy($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[width], $wInfo[height]);//生成混合图像这是系统的// imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[width],$wInfo[height], $alpha);//输出图像$ImageFun Image . $sInfo[type];//如果没有给出保存文件名默认为原图像名if (!$savename) {$savename $source;unlink($source);}//保存图像,如果是jpg,则设置一下水印质量 此处为修改过的if ($sInfo[type] jpg || $sInfo[type] jpeg) {imagejpeg($sImage, $savename, 90);//第3个参数即使质量大小因为只有imagejpeg支持这个参数} else {$ImageFun($sImage, $savename);}//$ImageFun($sImage, $savename);//这是系统的imagedestroy($sImage);}