水印功能毛边怎么办?

浏览:478 发布日期:2015/08/23 分类:求助交流
//增加本地图片水印 www.5ucms.com
function addwatermark($savepath){
    $picwatermarktype = C('picwatermarktype'); //读取配置 是否添加水印
    if($picwatermarktype>0 and strstr($savepath,'uploadfile')){
        $savepath = str_ireplace('./', '/', $savepath);
        $savepath = '.'.$savepath; 
        $image = new \Think\Image();
        $preimg = $image -> open($savepath);
        if($preimg){ 
            $picwatermarkimg = '.'.C('picwatermarkimg');//读取水印图片 
            $qid = $preimg -> water($picwatermarkimg,$picwatermarktype,C('picwatermarkalpha')) -> save($savepath); 
            if($qid){return true;}
        }
    }
    return false;
}
效果图
http://php.5ucms.com/index.php/content/index/id/14

我用的gif加80半透明 感觉有毛边

还有个问题是 怎么让上方的函数出错时 不提示?
有时 原图找不到 或 水印图片找不到 就会报错 如果能作个判断呢?
图片能open就继续 不能open就返回false
最佳答案
评论( 相关
后面还有条评论,点击查看>>