|
发表于 2017-11-15 13:55:34
|
显示全部楼层
|阅读模式
来自 中国–河南–新乡
修改文件:\source\class\class_image.php
修改原理:计算水印大小和图片大小,每次偏移一个水印的位置重复打水印;
由于discuz支持png和gif两种水印,因此本方法涉及两处修改:
修改1属于支持png水印,修改2属于支持gif水印;
修改1:大概第475行原始代码
- if($this->param['watermarktype'][$type] == 'png') {
- imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
- }
复制代码 修改为- if($this->param['watermarktype'][$type] == 'png') {
- //修改1 开始
- //imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
- if(intval($this->imginfo['width']/$logo_w)>=3){
- $wblank=($logo_w+$this->imginfo['width']%$logo_w)/intval($this->imginfo['width']/$logo_w);
- $hblank=($logo_h+$this->imginfo['height']%$logo_h)/intval($this->imginfo['height']/$logo_h);
- for($x = $wblank;$x+$logo_w<=$this->imginfo['width'];$x=$x+$logo_w+$wblank){
- for($y = $hblank;$y+$logo_h<=$this->imginfo['height'];$y=$y+$logo_h+$hblank){
- imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
- }
- }
- }else{
- for($x = 5;$x+$logo_w<=$this->imginfo['width'];$x=$x+$logo_w+10){
- for($y = 5;$y+$logo_h<=$this->imginfo['height'];$y=$y+$logo_h+10){
- imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
- }
- }
- }
- //修改1 结束
- }
复制代码 修改2:大概500行,原始代码为:- else {
- imageAlphaBlending($watermark_logo, true);
- imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $this->param['watermarktrans'][$type]);
- }
复制代码 修改为:- else {
- imageAlphaBlending($watermark_logo, true);
- //修改2 开始
- if(intval($this->imginfo['width']/$logo_w)>=3){
- $wblank=($logo_w+$this->imginfo['width']%$logo_w)/intval($this->imginfo['width']/$logo_w);
- $hblank=($logo_h+$this->imginfo['height']%$logo_h)/intval($this->imginfo['height']/$logo_h);
- for($x = $wblank;$x+$logo_w<=$this->imginfo['width'];$x=$x+$logo_w+$wblank){
- for($y = $hblank;$y+$logo_h<=$this->imginfo['height'];$y=$y+$logo_h+$hblank){
- imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $this->param['watermarktrans'][$type]);
- }
- }
- }else{
- for($x = 5;$x+$logo_w<=$this->imginfo['width'];$x=$x+$logo_w+10){
- for($y = 5;$y+$logo_h<=$this->imginfo['height'];$y=$y+$logo_h+10){
- imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $this->param['watermarktrans'][$type]);
- }
- }
- }
- //imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $this->param['watermarktrans'][$type]);
- //修改2 结束
- }
复制代码 修改后的水印平铺效果
|
|