效果如上图,底部水印+图片水印修改方法:source\class\class_image.php
搜索- imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
复制代码 下边添加- //@dly start
- global $_G;
- //自定义(开png水印时无法获取文字水印的参数,所以自定义)
- $this->param['watermarktext']['fontpath'][$type] = 'static/image/seccode/font/ch/msyh.ttf';
- $this->param['watermarktext']['size'][$type] = 9;
- $this->param['watermarktext']['color'][$type] = '255,255,255';
- $this->param['watermarktext']['shadowcolor'][$type] = '';
- $username = $_G['username'];
- $bbname = $_G['setting']['bbname'];
- $siteurl = $_G['setting']['siteurl'];
- if($this->imginfo['width'] >= 260 && $this->imginfo['width'] <= 324) {
- $wtext = "该图片由 $username 上传至 $bbname ";
- }elseif ($this->imginfo['width'] >= 325 && $this->imginfo['width'] <= 425) {
- $wtext = "该图片由 $username 上传至 $bbname $siteurl";
- }elseif ($this->imginfo['width'] >= 426 && $this->imginfo['width'] <= 585) {
- $wtext = "该图片由 $username 上传至 $bbname $siteurl 版权归原创者所有";
- }elseif ($this->imginfo['width'] >= 586) {
- $wtext = "该图片于 ".date('Y-m-d G:i:s')." 由 $username 上传至 $bbname($siteurl) 版权归原创者所有";
- }
- $watermarktextcvt = iconv('GB2312', 'UTF-8', $wtext);
- if(!function_exists('imagettfbbox') || !function_exists('imagettftext') || !function_exists('imagecolorallocate')) {
- return -4;
- }
- if(!class_exists('Chinese')) {
- include libfile('class/chinese');
- }
- //$watermarktextcvt = pack("H*", $this->param['watermarktext']['text'][$type]);
- $box = imagettfbbox($this->param['watermarktext']['size'][$type], $this->param['watermarktext']['angle'][$type], $this->param['watermarktext']['fontpath'][$type], $watermarktextcvt);
- $logo_h = max($box[1], $box[3]) - min($box[5], $box[7]);
- $logo_w = max($box[2], $box[4]) - min($box[0], $box[6]);
- $ax = min($box[0], $box[6]) * -1;
- $ay = min($box[5], $box[7]) * -1;
复制代码
Discuz教程网(www.discuz.1314study.com)原创内容,转载注明出处
代码中的- $this->param['watermarktext']['fontpath'][$type] = 'static/image/seccode/font/ch/msyh.ttf';
- $this->param['watermarktext']['size'][$type] = 9;
- $this->param['watermarktext']['color'][$type] = '255,255,255';
复制代码 分别对应字体、大小、RGB颜色
底部黑条水印在下载远程图片时会出现重复添加水印的问题 |