Discuz教程网

Discuz!X2图片底部黑条水印任意文字,并与图片水印共存

[复制链接]
原创
authicon dly 发表于 2014-1-25 15:53:11 | 显示全部楼层 |阅读模式
072751oeublppunu2uabpu.jpg

效果如上图,底部水印+图片水印修改方法:source\class\class_image.php
搜索
  1. imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
复制代码
下边添加
  1. //@dly start
  2.                                global $_G;
  3. //自定义(开png水印时无法获取文字水印的参数,所以自定义)
  4. $this->param['watermarktext']['fontpath'][$type] = 'static/image/seccode/font/ch/msyh.ttf';
  5. $this->param['watermarktext']['size'][$type] = 9;
  6. $this->param['watermarktext']['color'][$type] = '255,255,255';
  7. $this->param['watermarktext']['shadowcolor'][$type] = '';
  8. $username = $_G['username'];
  9. $bbname = $_G['setting']['bbname'];
  10. $siteurl = $_G['setting']['siteurl'];
  11. if($this->imginfo['width'] >= 260 && $this->imginfo['width'] <= 324) {
  12.         $wtext = "该图片由 $username 上传至 $bbname ";
  13. }elseif ($this->imginfo['width'] >= 325 && $this->imginfo['width'] <= 425) {
  14.         $wtext = "该图片由 $username 上传至 $bbname $siteurl";
  15. }elseif ($this->imginfo['width'] >= 426  && $this->imginfo['width'] <= 585) {
  16.         $wtext = "该图片由 $username 上传至 $bbname $siteurl 版权归原创者所有";
  17. }elseif ($this->imginfo['width'] >= 586) {
  18.         $wtext = "该图片于 ".date('Y-m-d G:i:s')." 由 $username 上传至 $bbname($siteurl) 版权归原创者所有";
  19. }
  20. $watermarktextcvt = iconv('GB2312', 'UTF-8', $wtext);

  21. if(!function_exists('imagettfbbox') || !function_exists('imagettftext') || !function_exists('imagecolorallocate')) {
  22.         return -4;
  23. }
  24. if(!class_exists('Chinese')) {
  25.         include libfile('class/chinese');
  26. }

  27. //$watermarktextcvt = pack("H*", $this->param['watermarktext']['text'][$type]);
  28. $box = imagettfbbox($this->param['watermarktext']['size'][$type], $this->param['watermarktext']['angle'][$type], $this->param['watermarktext']['fontpath'][$type], $watermarktextcvt);
  29. $logo_h = max($box[1], $box[3]) - min($box[5], $box[7]);
  30. $logo_w = max($box[2], $box[4]) - min($box[0], $box[6]);
  31. $ax = min($box[0], $box[6]) * -1;
  32. $ay = min($box[5], $box[7]) * -1;
复制代码
游客,如果您要查看本帖隐藏内容请回复

Discuz教程网(www.discuz.1314study.com)原创内容,转载注明出处
代码中的
  1. $this->param['watermarktext']['fontpath'][$type] = 'static/image/seccode/font/ch/msyh.ttf';
  2.                                 $this->param['watermarktext']['size'][$type] = 9;
  3.                                 $this->param['watermarktext']['color'][$type] = '255,255,255';
复制代码
分别对应字体、大小、RGB颜色
底部黑条水印在下载远程图片时会出现重复添加水印的问题



上一篇:网上刷会员的网址
下一篇:空间3g版的社交搜索每次点都转到腾讯网,完全无法用,前段日子还可以来搜日志的,怎么
authicon 黄河一号 发表于 2014-1-29 04:10:23 | 显示全部楼层
进来学习一下。
authicon luoj5858 发表于 2016-3-4 23:12:32 | 显示全部楼层
正想要呢,看看下
authicon luoj5858 发表于 2016-3-4 23:25:00 | 显示全部楼层
X3的能用吗?
authicon lee5152 发表于 2016-3-4 23:45:56 | 显示全部楼层
进来学习一下,不知道x3.2能不能用
authicon 2016 发表于 2016-6-15 06:05:27 | 显示全部楼层
Discuz!X2图片底部黑条水印任意文字
authicon 饭叔叔 发表于 2016-6-26 08:11:00 | 显示全部楼层
85方法反反复复
authicon 8444880 发表于 2016-9-2 07:06:41 | 显示全部楼层
总想着对方斯蒂芬斯蒂芬
authicon 8834629 发表于 2016-9-10 11:37:11 | 显示全部楼层
如果您要查看本帖隐藏内容请回复
authicon QQ_49DD6A 发表于 2016-9-29 14:44:52 | 显示全部楼层
不错的样子
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-4-27 06:50

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表