XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
decorations.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 */
31  function roundCorners(phmagick $p,$i = 15){
32 
33  //original idea from Leif ��strand <leif@sitelogic.fi>
34  $cmd = $p->getBinary('convert');
35  $cmd .= ' "' . $p->getSource().'"' ;
36  $cmd .= ' ( +clone -threshold -1 ' ;
37  $cmd .= "-draw \"fill black polygon 0,0 0,$i $i,0 fill white circle $i,$i $i,0\" ";
38  $cmd .= '( +clone -flip ) -compose Multiply -composite ';
39  $cmd .= '( +clone -flop ) -compose Multiply -composite ';
40  $cmd .= ') +matte -compose CopyOpacity -composite ' ;
41  $cmd .= ' "' . $p->getDestination().'"' ;
42 
43 
44  $p->execute($cmd);
45  $p->setSource($p->getDestination());
46  $p->setHistory($p->getDestination());
47  return $p ;
48  }
49 
50  function dropShadow(phmagick $p,$color = '#000', $offset = 4, $transparency = 60, $top = 4, $left=4){
51 
52  $top = $top > 0 ? '+' . $top : $top;
53  $left = $left > 0 ? '+' . $left : $left;
54 
55  $cmd = $p->getBinary('convert');
56  $cmd .= ' -page '.$top.$left.' "' . $p->getSource().'"' ;
57  $cmd .= ' -matte ( +clone -background "'. $color .'" -shadow '. $transparency.'x4+'.$offset.'+'.$offset.' ) +swap ';
58  $cmd .= ' -background none -mosaic ';
59  $cmd .= ' "' . $p->getDestination().'"' ;
60 
61  $p->execute($cmd);
62  $p->setSource($p->getDestination());
63  $p->setHistory($p->getDestination());
64  return $p ;
65  }
66 
67  function glow(phmagick $p, $color='#827f00',$offset = 10, $transparency=60){
68 
69  $p->requirePlugin('info');
70  list ($w, $h) = $p->getInfo($p->getSource());
71 
72 
73  $cmd = $p->getBinary('convert');
74 
75  $cmd .= ' "' . $p->getSource() .'" ' ;
76  $cmd .= '( +clone -background "'.$color.'" -shadow '.$transparency.'x'.$offset.'-'.($offset/4).'+'.($offset/4).' ) +swap -background none -layers merge +repage ';
77 
78  $cmd .= ' "' . $p->getDestination().'"' ;
79 
80  $p->execute($cmd);
81  $p->setSource($p->getDestination());
82  $p->setHistory($p->getDestination());
83  return $p ;
84  }
85 
94  function fakePolaroid(phmagick $p,$rotate = 6 , $borderColor = "#fff", $background ="none"){
95  $cmd = $p->getBinary('convert');
96  $cmd .= ' "' . $p->getSource().'"' ;
97  $cmd .= ' -bordercolor "'. $borderColor.'" -border 6 -bordercolor grey60 -border 1 -background "none" -rotate '. $rotate .' -background black ( +clone -shadow 60x4+4+4 ) +swap -background "'. $background.'" -flatten';
98  $cmd .= ' ' . $p->getDestination() ;
99 
100  //echo $cmd .'<br>';;
101  $ret = $p->execute($cmd);
102  $p->setSource($p->getDestination());
103  $p->setHistory($p->getDestination());
104  return $p ;
105  }
106 
116  function polaroid(phmagick $p, $format = null, $rotation= 6, $borderColor="snow", $shaddowColor = "black", $background="none"){
117 
118 
119 
120  if (get_class($format) == 'phMagickTextObject' ){
121  //
122  }else{
123  $tmp = new phMagickTextObject();
124  $tmp->text($format);
125  $format = $tmp ;
126  }
127 
128  $cmd = $p->getBinary('convert');
129  $cmd .= ' "' . $p->getSource() .'"' ;
130 
131 
132  if ($format->background !== false)
133  $cmd .= ' -background "' . $format->background . '"';
134 
135  if ($format->color !== false)
136  $cmd .= ' -fill "' . $format->color . '"' ;
137 
138  if ($format->font !== false)
139  $cmd .= ' -font ' . $format->font ;
140 
141  if ($format->fontSize !== false)
142  $cmd .= ' -pointsize ' . $format->fontSize ;
143 
144  if ($format->pGravity !== false)
145  $cmd .= ' -gravity ' . $format->pGravity ;
146 
147  if ($format->pText != '')
148  $cmd .= ' -set caption "' . $format->pText .'"';
149 
150  $cmd .= ' -bordercolor "'. $borderColor.'" -background "'.$background.'" -polaroid ' . $rotation .' -background "'. $background.'" -flatten ';
151  $cmd .= ' "' . $p->getDestination().'"' ;
152 
153  //echo $cmd .'<br>';;
154  $p->execute($cmd);
155  $p->setSource($p->getDestination());
156  $p->setHistory($p->getDestination());
157  return $p ;
158  }
159 
160  function border(phmagick $p,$borderColor = "#000", $borderSize ="1"){
161  $cmd = $p->getBinary('convert');
162  $cmd .= ' "' . $p->getSource() .'"';
163  $cmd .= ' -bordercolor "'. $borderColor.'" -border ' . $borderSize;
164  $cmd .= ' "' . $p->getDestination() .'"';
165 
166  $ret = $p->execute($cmd);
167  $p->setSource($p->getDestination());
168  $p->setHistory($p->getDestination());
169  return $p ;
170  }
171 
172 }
173 ?>