最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php给图片加水印函数
时间:2022-07-02 10:15:53 编辑:袖梨 来源:一聚教程网
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;
}
@exec($exec_str, $output, $return);
if(empty($return) && empty($output)) {
$this->attach['size'] = filesize($this->targetfile);
}
}
相关文章
- 黑神话悟空1.0.12.16581版本更新公告 12-27
- 光遇12.27红石碎片在哪里 12-27
- 无限暖暖翩翩愿飞去怎么样 无限暖暖翩翩愿飞去能力套装介绍 12-27
- 无限暖暖流星绚烂时怎么样 无限暖暖流星绚烂时套装介绍 12-27
- 无限暖暖1.1版本流星季怎么玩 无限暖暖1.1流星季版本活动介绍 12-27
- 第五人格孽蜥耶梦加得怎么样 第五人格孽蜥耶梦加得稀世时装介绍 12-27