久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

Discuz! 官方交流社區

標題: 小黑條文字水印,不破壞原圖,后臺控制文字及背景顏色,更新帶日期版本 [打印本頁]

作者: haoma1    時間: 2023-3-17 04:46
標題: 小黑條文字水印,不破壞原圖,后臺控制文字及背景顏色,更新帶日期版本
后臺設置文本水印文字時,雖然可以任意輸入,但不要輸英文或數字字符,輸一個中文,就可以了。



后臺設置:
啟用水印功能。
水印位置任選。
添加水印條件自定。
水印圖片類型選擇文字水印。
融合度質量100(其實多少都沒影響)。
文本水印文字,請輸入任意內容(一定要輸,不然出錯)
選擇自己上傳的字體。
文字大小8-10自己看著辦。
文本水印顯示角度:0
水印字體顏色【自己測試效果】
水印陰影顏色【自己測試效果】
其它無視了,提交測試吧。



修改方法:
打開\source\class目錄下class_image.php文件
查找

  1. } elseif($this->param['watermarktype'][$type] == 'text') {
  2.                                 if(($this->param['watermarktext']['shadowx'][$type] || $this->param['watermarktext']['shadowy'][$type]) && $this->param['watermarktext']['shadowcolor'][$type]) {
  3.                                         $shadowcolorrgb = explode(',', $this->param['watermarktext']['shadowcolor'][$type]);
  4.                                         $shadowcolor = imagecolorallocate($dst_photo, $shadowcolorrgb[0], $shadowcolorrgb[1], $shadowcolorrgb[2]);
  5.                                         imagettftext($dst_photo, $this->param['watermarktext']['size'][$type], $this->param['watermarktext']['angle'][$type], $x + $ax + $this->param['watermarktext']['shadowx'][$type], $y + $ay + $this->param['watermarktext']['shadowy'][$type], $shadowcolor, $this->param['watermarktext']['fontpath'][$type], $watermarktextcvt);
  6.                                 }

  7.                                 $colorrgb = explode(',', $this->param['watermarktext']['color'][$type]);
  8.                                 $color = imagecolorallocate($dst_photo, $colorrgb[0], $colorrgb[1], $colorrgb[2]);
  9.                                 imagettftext($dst_photo, $this->param['watermarktext']['size'][$type], $this->param['watermarktext']['angle'][$type], $x + $ax, $y + $ay, $color, $this->param['watermarktext']['fontpath'][$type], $watermarktextcvt);
  10.                         } else {
復制代碼


替換為:


  1. } elseif($this->param['watermarktype'][$type] == 'text' && $this->imginfo['width'] >= 250) {
  2.         $objTmpImg = @imagecreatetruecolor($this->imginfo['width'], $this->imginfo['height']+16);
  3.         @imagecopy($objTmpImg, $dst_photo, 0, 0, 0, 0, $this->imginfo['width'], $this->imginfo['height']);
  4.         $dst_photo = $objTmpImg;
  5.         $bg_x1 = 0;
  6.         $bg_y1 = $this->imginfo['height'];
  7.         $bg_x2 = $this->imginfo['width'];
  8.         $bg_y2 = $this->imginfo['height']+16;
  9.                 $shadowcolorrgb = explode(',', $this->param['watermarktext']['shadowcolor'][$type]);
  10.         $shadowcolor = imagecolorallocate($dst_photo, $shadowcolorrgb[0], $shadowcolorrgb[1], $shadowcolorrgb[2]);
  11.         imagefilledrectangle($dst_photo, $bg_x1, $bg_y1, $bg_x2, $bg_y2, $shadowcolor);
  12.                           

  13.         $colorrgb = explode(',', $this->param['watermarktext']['color'][$type]);
  14.         $n = $_G['member']['username'];
  15.                 $w = $_G['setting']['bbname'];
  16.                 $u = $_G['setting']['siteurl'];
  17.                 preg_match("/^(http:\/\/)?([^\/]+)/i",$u, $ur);
  18.                 $url = $ur[2];
  19.                 preg_match("/[^\.\/]+\.[^\.\/]+$/", $url, $ur);
  20.                 $wtext = "該圖片由網友上傳,版權歸原創者所有 ".date('Y-m-d h:i')."";
  21.         $watermarktextcvt = $wtext;
  22.         $color = imagecolorallocate($dst_photo, $colorrgb[0], $colorrgb[1], $colorrgb[2]);
  23.         imagettftext($dst_photo, $this->param['watermarktext']['size'][$type], $this->param['watermarktext']['angle'][$type], $ax + 3, $this->imginfo['height'] + $ay + 1, $color, $this->param['watermarktext']['fontpath'][$type], $watermarktextcvt);
  24.                         } else {
復制代碼









歡迎光臨 Discuz! 官方交流社區 (http://www.9999xn.com/) Powered by Discuz! W1.0