Php watermarks images
Last Update:2017-01-13
Source: Internet
Author: User
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! = '000000 '? '-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 ['translate'] | $ watermarktext ['translate']? 'Translate'. $ watermarktext ['translate']. ','. $ watermarktext ['translate']: '';
$ 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 ''. $ watermarktextcvt .''"'.
''. $ This-> targetfile.''. $ targetfile;
}
@ Exec ($ exec_str, $ output, $ return );
If (empty ($ return) & empty ($ output )){
$ This-> attach ['size'] = filesize ($ this-> targetfile );
}
}