php给图片加水印函数
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-20 09:49:15 浏览: 评论:0
- function Watermark_IM($preview = 0) {
- global $watermarkstatus, $watermarktype, $watermarktrans, $watermarkquality, $watermarktext, $imageimpath;
- $watermarkstatus = $GLOBALS['forum']['disablewatermark'] ? 0 : $watermarkstatus;
- switch($watermarkstatus) {
- case 1:
- $gravity = 'NorthWest';
- break;
- case 2:
- $gravity = 'North';
- break;
- case 3:
- $gravity = 'NorthEast';
- break;
- case 4:
- $gravity = 'West';
- break;
- case 5:
- $gravity = 'Center';
- break;
- case 6:
- $gravity = 'East';
- break;
- case 7:
- $gravity = 'SouthWest';
- break;
- case 8:
- $gravity = 'South';
- break;
- case 9:
- $gravity = 'SouthEast';
- break;
- }
- $targetfile = !$preview ? $this->targetfile : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg';
- if($watermarktype < 2) {
- $watermark_file = $watermarktype == 1 ? DISCUZ_ROOT.'./images/common/watermark.png' : DISCUZ_ROOT.'./images/common/watermark.gif';
- $exec_str = $imageimpath.'/composite'.
- ($watermarktype != 1 && $watermarktrans != '100' ? ' -watermark '.$watermarktrans.'%' : '').
- ' -quality '.$watermarkquality.
- ' -gravity '.$gravity.
- ' '.$watermark_file.' '.$this->targetfile.' '.$targetfile;
- } else {
- $watermarktextcvt = str_replace(array("n", "r", "'"), array('', '', '''), pack("H*", $watermarktext['text']));
- $watermarktext['angle'] = -$watermarktext['angle'];
- $translate = $watermarktext['translatex'] || $watermarktext['translatey'] ? ' translate '.$watermarktext['translatex'].','.$watermarktext['translatey'] : '';
- $skewX = $watermarktext['skewx'] ? ' skewX '.$watermarktext['skewx'] : '';
- $skewY = $watermarktext['skewy'] ? ' skewY '.$watermarktext['skewy'] : '';
- $exec_str = $imageimpath.'/convert'.
- ' -quality '.$watermarkquality.
- ' -font "'.$watermarktext['fontpath'].'"'.
- ' -pointsize '.$watermarktext['size'].
- (($watermarktext['shadowx'] || $watermarktext['shadowy']) && $watermarktext['shadowcolor'] ?
- ' -fill "rgb('.$watermarktext['shadowcolor'].')"'.
- ' -draw "'.
- ' gravity '.$gravity.$translate.$skewX.$skewY.
- ' rotate '.$watermarktext['angle'].
- ' text '.$watermarktext['shadowx'].','.$watermarktext['shadowy'].' ''.$watermarktextcvt.''"' : '').
- ' -fill "rgb('.$watermarktext['color'].')"'.
- ' -draw "'.
- ' gravity '.$gravity.$translate.$skewX.$skewY.
- ' rotate '.$watermarktext['angle'].
- ' text 0,0 ''.$watermarktextcvt.''"'.
- ' '.$this->targetfile.' '.$targetfile;
- }//开源代码phpfensi.com
- @exec($exec_str, $output, $return);
- if(empty($return) && empty($output)) {
- $this->attach['size'] = filesize($this->targetfile);
- }
- }
Tags: php图片水印 php水印函数
- 上一篇:php创建缩略图程序
- 下一篇:php 验证码图片程序
相关文章
- ·PHP为图片添加水印的实例(2013-11-14)
- ·php给图片加水印实例函数(2014-08-18)
- ·php图片加中文水印实现代码(2014-08-19)
- ·php 图片上传代码,支持水印,缩略图(2014-08-19)
- ·php图片增加中文与图片水印代码(2014-08-19)
- ·php图片水印代码 (2014-08-19)
- ·php生成艺术字体图片水印代码(2014-08-19)
- ·php 图片水印中文乱码解决方法(2014-08-19)
- ·php上传图片加水印,图片水印,文字水印(2014-08-19)
- ·php实现图片添加文字水印程序代码(2014-08-26)
- ·php图片上传自动给图片加水印(2014-09-22)
- ·利用php GD库 文字图片水印 缩略图(2015-12-24)
- ·php使用GD库实现文字图片水印及缩略图教程(2016-01-20)
- ·PHP添加图片水印、压缩、剪切的封装类(2021-06-16)
- ·php图片水印添加、压缩、剪切的封装类实现(2021-06-17)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)