无为清净楼资源网 Design By www.qnjia.com

复制代码 代码如下:
//原始图像
       $dst = "/upload/20120914/20120914040740-0.jpg"; //注意图片路径要正确
       //得到原始图片信息
       $dst_info = getimagesize($dst); 
       switch ($dst_info[2])
       {
        case 1:
        $dst_im =imagecreatefromgif($dst);break;
        case 2:
        $dst_im =imagecreatefromjpeg($dst);break;
        case 3:
        $dst_im =imagecreatefrompng($dst);break;
        case 6:
        $dst_im =imagecreatefromwbmp($dst);break;
        default:
        die("不支持的文件类型1");exit;
       }
       //水印图像
       $src = "/images/shuiyin.png"; //注意路径要写对
       $src_info = getimagesize($src);
       switch ($src_info[2])
       {
        case 1:
        $src_im =imagecreatefromgif($src);break;
        case 2:
        $src_im =imagecreatefromjpeg($src);break;
        case 3:
        $src_im =imagecreatefrompng($src);break;
        case 6:
        $src_im =imagecreatefromwbmp($src);break;
        default:
        die("不支持的文件类型1");exit;
       }

       //半透明格式水印
       //$alpha = 50;//水印透明度
       //imagecopymerge($dst_im,$src_im,$dst_info[0]-$src_info[0]-10,$dst_info[1]-$src_info[1]-10,0,0,$src_info[0],$src_info[1],$alpha);

       //支持png本身透明度的方式
       imagecopy($dst_im,$src_im,$dst_info[0]-$src_info[0]-10,$dst_info[1]-$src_info[1]-10,0,0,$src_info[0],$src_info[1]);

       //保存图片
       switch ($dst_info[2]){
        case 1:
        imagegif($dst_im,$dst);break;
        case 2:
        imagejpeg($dst_im,$dst);break;
        case 3:
        imagepng($dst_im,$dst);break;
        case 6:
        imagewbmp($dst_im,$dst);break;
        default:
        die("不支持的文件类型2");exit;
       }
       imagedestroy($dst_im);
       imagedestroy($src_im);  

标签:
水印

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com