XOOPS RMCommon Utilities
2.1.8.91RC
Main Page
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
color.php
Go to the documentation of this file.
1
<?php
2
/*
3
+--------------------------------------------------------------------------------------------+
4
| DISCLAIMER - LEGAL NOTICE - |
5
+--------------------------------------------------------------------------------------------+
6
| |
7
| This program is free for non comercial use, see the license terms available at |
8
| http://www.francodacosta.com/licencing/ for more information |
9
| |
10
| This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
11
| without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
| |
13
| USE IT AT YOUR OWN RISK |
14
| |
15
| |
16
+--------------------------------------------------------------------------------------------+
17
18
*/
30
class
phMagick_color
{
31
function
darken
(
phmagick
$p
,$alphaValue = 50){
32
$percent = 100 - (int) $alphaValue;
33
34
//get original file dimentions
35
36
list ($width, $height) = $p->getInfo();
37
38
$cmd = $p->
getBinary
(
'composite'
);
39
$cmd .=
' -blend '
. $percent .
' '
;
40
$cmd .=
'"'
.$p->getSource().
'"'
;
41
$cmd .=
' -size '
. $width .
'x'
. $height.
' xc:black '
;
42
$cmd .=
'-matte "'
. $p->
getDestination
().
'"'
;
43
44
$p->
execute
($cmd);
45
$p->
setSource
($p->
getDestination
());
46
$p->
setHistory
($p->
getDestination
());
47
return
$p
;
48
}
49
59
function
brighten
(
phmagick
$p
, $alphaValue = 50){
60
61
$percent = 100 - (int) $alphaValue;
62
63
//get original file dimentions
64
65
list ($width, $height) = $p->getInfo();
66
67
$cmd = $p->
getBinary
(
'composite'
);
68
$cmd .=
' -blend '
. $percent .
' '
;
69
$cmd .=
'"'
.$p->getSource().
'"'
;
70
$cmd .=
' -size '
. $width .
'x'
. $height.
' xc:white '
;
71
$cmd .=
'-matte "'
. $p->
getDestination
().
'"'
;
72
73
$p->
execute
($cmd);
74
$p->
setSource
($p->
getDestination
());
75
$p->
setHistory
($p->
getDestination
());
76
return
$p
;
77
}
78
82
// function toGrayScale(phmagick $p){
83
// $cmd = $p->getBinary('convert');
84
// $cmd .= ' "' . $p->getSource() .'"';
85
// $cmd .= ' -colorspace Gray ';
86
// $cmd .= ' "' . $p->getDestination().'"' ;
87
//
88
// $p->execute($cmd);
89
// $p->setSource($p->getDestination());
90
// $p->setHistory($p->getDestination());
91
// return $p ;
92
// }
93
94
function
toGreyScale
(
phmagick
$p
, $enhance=2){
95
$cmd = $p->
getBinary
(
'convert'
);
96
$cmd .=
' -modulate 100,0 '
;
97
$cmd .=
' -sigmoidal-contrast '
.$enhance.
'x50%'
;
98
$cmd .=
' -background "none" "'
. $p->
getSource
().
'"'
;
99
$cmd .=
' "'
. $p->
getDestination
() .
'"'
;
100
101
$p->
execute
($cmd);
102
$p->
setSource
($p->
getDestination
());
103
$p->
setHistory
($p->
getDestination
());
104
return
$p
;
105
}
106
110
function
invertColors
(
phmagick
$p
){
111
$cmd = $p->
getBinary
(
'convert'
);
112
$cmd .=
' "'
. $p->
getSource
() .
'"'
;
113
$cmd .=
' -negate '
;
114
$cmd .=
' "'
. $p->
getDestination
() .
'"'
;
115
116
$p->
execute
($cmd);
117
$p->
setSource
($p->
getDestination
());
118
$p->
setHistory
($p->
getDestination
());
119
return
$p
;
120
}
121
122
function
sepia
(
phmagick
$p
, $tone = 90){
123
$cmd = $p->
getBinary
(
'convert'
);
124
$cmd .=
' -sepia-tone '
. $tone .
'% '
;
125
$cmd .=
' -modulate 100,50 '
;
126
$cmd .=
' -normalize '
;
127
$cmd .=
' -background "none" "'
. $p->
getSource
() .
'"'
;
128
$cmd .=
' "'
. $p->
getDestination
().
'"'
;
129
$p->
execute
($cmd);
130
$p->
setSource
($p->
getDestination
());
131
$p->
setHistory
($p->
getDestination
());
132
return
$p
;
133
}
134
135
function
autoLevels
(
phmagick
$p
){
136
$cmd = $p->
getBinary
(
'convert'
);
137
$cmd .=
' -normalize '
;
138
$cmd .=
' -background "none" "'
. $p->
getSource
().
'"'
;
139
$cmd .=
' "'
. $p->
getDestination
() .
'"'
;
140
141
$p->
execute
($cmd);
142
$p->
setSource
($p->
getDestination
());
143
$p->
setHistory
($p->
getDestination
());
144
return
$p
;
145
}
146
147
}
148
?>
L:
XOOPS_Allure
SVN_XOOPS2
RMC
rmcommon
trunk
rmcommon
class
plugins
color.php
Generated on Sun Mar 17 2013 20:41:05 for XOOPS RMCommon Utilities by
1.8.3.1