@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * CopyChannelsPalette operation class |
@@ -41,8 +41,9 @@ discard block |
||
41 | 41 | function execute($img, $channels) |
42 | 42 | { |
43 | 43 | $blank = array('red' => 0, 'green' => 0, 'blue' => 0); |
44 | - if (isset($channels['alpha'])) |
|
45 | - unset($channels['alpha']); |
|
44 | + if (isset($channels['alpha'])) { |
|
45 | + unset($channels['alpha']); |
|
46 | + } |
|
46 | 47 | |
47 | 48 | $width = $img->getWidth(); |
48 | 49 | $height = $img->getHeight(); |
@@ -53,15 +54,16 @@ discard block |
||
53 | 54 | $otci = $img->getTransparentColor(); |
54 | 55 | $TRGB = $img->getColorRGB($otci); |
55 | 56 | $tci = $copy->allocateColor($TRGB); |
56 | - } |
|
57 | - else |
|
57 | + } else |
|
58 | 58 | { |
59 | 59 | $otci = null; |
60 | 60 | $tci = null; |
61 | 61 | } |
62 | 62 | |
63 | - for ($x = 0; $x < $width; $x++) |
|
64 | - for ($y = 0; $y < $height; $y++) |
|
63 | + for ($x = 0; $x < $width; $x++) { |
|
64 | + for ($y = 0; |
|
65 | + } |
|
66 | + $y < $height; $y++) |
|
65 | 67 | { |
66 | 68 | $ci = $img->getColorAt($x, $y); |
67 | 69 | if ($ci === $otci) |
@@ -72,18 +74,21 @@ discard block |
||
72 | 74 | $RGB = $img->getColorRGB($ci); |
73 | 75 | |
74 | 76 | $newRGB = $blank; |
75 | - foreach ($channels as $channel) |
|
76 | - $newRGB[$channel] = $RGB[$channel]; |
|
77 | + foreach ($channels as $channel) { |
|
78 | + $newRGB[$channel] = $RGB[$channel]; |
|
79 | + } |
|
77 | 80 | |
78 | 81 | $color = $copy->getExactColor($newRGB); |
79 | - if ($color == -1) |
|
80 | - $color = $copy->allocateColor($newRGB); |
|
82 | + if ($color == -1) { |
|
83 | + $color = $copy->allocateColor($newRGB); |
|
84 | + } |
|
81 | 85 | |
82 | 86 | $copy->setColorAt($x, $y, $color); |
83 | 87 | } |
84 | 88 | |
85 | - if ($img->isTransparent()) |
|
86 | - $copy->setTransparentColor($tci); |
|
89 | + if ($img->isTransparent()) { |
|
90 | + $copy->setTransparentColor($tci); |
|
91 | + } |
|
87 | 92 | |
88 | 93 | return $copy; |
89 | 94 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * Flip operation class |
@@ -41,13 +41,14 @@ |
||
41 | 41 | |
42 | 42 | $width = $image->getWidth(); |
43 | 43 | $height = $image->getHeight(); |
44 | - for ($y = 0; $y < $height; $y++) |
|
45 | - imagecopy( |
|
44 | + for ($y = 0; $y < $height; $y++) { |
|
45 | + imagecopy( |
|
46 | 46 | $new->getHandle(), |
47 | 47 | $image->getHandle(), |
48 | 48 | 0, $y, 0, $height - $y - 1, |
49 | 49 | $width, 1 |
50 | 50 | ); |
51 | + } |
|
51 | 52 | return $new; |
52 | 53 | } |
53 | 54 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * CorrectGamma operation class |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * Merge operation class |
@@ -48,11 +48,12 @@ discard block |
||
48 | 48 | $result->alphaBlending(true); |
49 | 49 | $result->saveAlpha(true); |
50 | 50 | |
51 | - if ($pct == 0) |
|
52 | - return $result; |
|
51 | + if ($pct == 0) { |
|
52 | + return $result; |
|
53 | + } |
|
53 | 54 | |
54 | - if ($pct < 100) |
|
55 | - imagecopymerge( |
|
55 | + if ($pct < 100) { |
|
56 | + imagecopymerge( |
|
56 | 57 | $result->getHandle(), |
57 | 58 | $overlay->getHandle(), |
58 | 59 | $x, $y, 0, 0, |
@@ -60,14 +61,15 @@ discard block |
||
60 | 61 | $overlay->getHeight(), |
61 | 62 | $pct |
62 | 63 | ); |
63 | - else |
|
64 | - imagecopy( |
|
64 | + } else { |
|
65 | + imagecopy( |
|
65 | 66 | $result->getHandle(), |
66 | 67 | $overlay->getHandle(), |
67 | 68 | $x, $y, 0, 0, |
68 | 69 | $overlay->getWidth(), |
69 | 70 | $overlay->getHeight() |
70 | 71 | ); |
72 | + } |
|
71 | 73 | |
72 | 74 | return $result; |
73 | 75 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * ApplyFilter operation class |
@@ -50,14 +50,15 @@ |
||
50 | 50 | { |
51 | 51 | $new = $image->asTrueColor(); |
52 | 52 | |
53 | - if (in_array($filter, self::$one_arg_filters)) |
|
54 | - imagefilter($new->getHandle(), $filter, $arg1); |
|
55 | - elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) |
|
56 | - imagefilter($new->getHandle(), $filter, $arg1, $arg2); |
|
57 | - elseif ($filter == IMG_FILTER_COLORIZE) |
|
58 | - imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); |
|
59 | - else |
|
60 | - imagefilter($new->getHandle(), $filter); |
|
53 | + if (in_array($filter, self::$one_arg_filters)) { |
|
54 | + imagefilter($new->getHandle(), $filter, $arg1); |
|
55 | + } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) { |
|
56 | + imagefilter($new->getHandle(), $filter, $arg1, $arg2); |
|
57 | + } elseif ($filter == IMG_FILTER_COLORIZE) { |
|
58 | + imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); |
|
59 | + } else { |
|
60 | + imagefilter($new->getHandle(), $filter); |
|
61 | + } |
|
61 | 62 | |
62 | 63 | return $new; |
63 | 64 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * Crop operation class |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | $left = 0; |
52 | 52 | } |
53 | 53 | |
54 | - if ($width > $img->getWidth() - $left) |
|
55 | - $width = $img->getWidth() - $left; |
|
54 | + if ($width > $img->getWidth() - $left) { |
|
55 | + $width = $img->getWidth() - $left; |
|
56 | + } |
|
56 | 57 | |
57 | 58 | if ($top < 0) |
58 | 59 | { |
@@ -60,8 +61,9 @@ discard block |
||
60 | 61 | $top = 0; |
61 | 62 | } |
62 | 63 | |
63 | - if ($height > $img->getHeight() - $top) |
|
64 | - $height = $img->getHeight() - $top; |
|
64 | + if ($height > $img->getHeight() - $top) { |
|
65 | + $height = $img->getHeight() - $top; |
|
66 | + } |
|
65 | 67 | |
66 | 68 | $new = $img->doCreate($width, $height); |
67 | 69 | |
@@ -71,8 +73,7 @@ discard block |
||
71 | 73 | imagecopyresized( |
72 | 74 | $new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height |
73 | 75 | ); |
74 | - } |
|
75 | - else |
|
76 | + } else |
|
76 | 77 | { |
77 | 78 | $new->alphaBlending(false); |
78 | 79 | $new->saveAlpha(true); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * Rotate operation class |
@@ -41,32 +41,35 @@ |
||
41 | 41 | function execute($image, $angle, $bgColor, $ignoreTransparent) |
42 | 42 | { |
43 | 43 | $angle = -floatval($angle); |
44 | - if ($angle < 0) |
|
45 | - $angle = 360 + $angle; |
|
44 | + if ($angle < 0) { |
|
45 | + $angle = 360 + $angle; |
|
46 | + } |
|
46 | 47 | $angle = $angle % 360; |
47 | 48 | |
48 | - if ($angle == 0) |
|
49 | - return $image->copy(); |
|
49 | + if ($angle == 0) { |
|
50 | + return $image->copy(); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | if ($bgColor === null) |
52 | 54 | { |
53 | - if ($image->isTransparent()) |
|
54 | - $bgColor = $image->getTransparentColor(); |
|
55 | - else |
|
55 | + if ($image->isTransparent()) { |
|
56 | + $bgColor = $image->getTransparentColor(); |
|
57 | + } else |
|
56 | 58 | { |
57 | 59 | $tc = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127); |
58 | 60 | |
59 | 61 | if ($image->isTrueColor()) |
60 | 62 | { |
61 | 63 | $bgColor = $image->getExactColorAlpha($tc); |
62 | - if ($bgColor == -1) |
|
63 | - $bgColor = $image->allocateColorAlpha($tc); |
|
64 | - } |
|
65 | - else |
|
64 | + if ($bgColor == -1) { |
|
65 | + $bgColor = $image->allocateColorAlpha($tc); |
|
66 | + } |
|
67 | + } else |
|
66 | 68 | { |
67 | 69 | $bgColor = $image->getExactColor($tc); |
68 | - if ($bgColor == -1) |
|
69 | - $bgColor = $image->allocateColor($tc); |
|
70 | + if ($bgColor == -1) { |
|
71 | + $bgColor = $image->allocateColor($tc); |
|
72 | + } |
|
70 | 73 | } |
71 | 74 | } |
72 | 75 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * ApplyConvolution operation class |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Gasper Kozak |
|
4 | - * @copyright 2007, 2008, 2009 |
|
3 | + * @author Gasper Kozak |
|
4 | + * @copyright 2007, 2008, 2009 |
|
5 | 5 | |
6 | 6 | This file is part of WideImage. |
7 | 7 | |
@@ -18,9 +18,8 @@ discard block |
||
18 | 18 | You should have received a copy of the GNU Lesser General Public License |
19 | 19 | along with WideImage; if not, write to the Free Software |
20 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 | - |
|
22 | - * @package Internal/Operations |
|
23 | - **/ |
|
21 | + * @package Internal/Operations |
|
22 | + **/ |
|
24 | 23 | |
25 | 24 | /** |
26 | 25 | * An Exception for when an invalid fit method is passed |
@@ -54,33 +54,35 @@ discard block |
||
54 | 54 | protected function prepareDimensions($img, $width, $height, $fit) |
55 | 55 | { |
56 | 56 | list($width, $height) = WideImage_Coordinate::fixForResize($img, $width, $height); |
57 | - if ($width === 0 || $height === 0) |
|
58 | - return array('width' => 0, 'height' => 0); |
|
57 | + if ($width === 0 || $height === 0) { |
|
58 | + return array('width' => 0, 'height' => 0); |
|
59 | + } |
|
59 | 60 | |
60 | - if ($fit == null) |
|
61 | - $fit = 'inside'; |
|
61 | + if ($fit == null) { |
|
62 | + $fit = 'inside'; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | $dim = array(); |
64 | 66 | if ($fit == 'fill') |
65 | 67 | { |
66 | 68 | $dim['width'] = $width; |
67 | 69 | $dim['height'] = $height; |
68 | - } |
|
69 | - elseif ($fit == 'inside' || $fit == 'outside') |
|
70 | + } elseif ($fit == 'inside' || $fit == 'outside') |
|
70 | 71 | { |
71 | 72 | $rx = $img->getWidth() / $width; |
72 | 73 | $ry = $img->getHeight() / $height; |
73 | 74 | |
74 | - if ($fit == 'inside') |
|
75 | - $ratio = ($rx > $ry) ? $rx : $ry; |
|
76 | - else |
|
77 | - $ratio = ($rx < $ry) ? $rx : $ry; |
|
75 | + if ($fit == 'inside') { |
|
76 | + $ratio = ($rx > $ry) ? $rx : $ry; |
|
77 | + } else { |
|
78 | + $ratio = ($rx < $ry) ? $rx : $ry; |
|
79 | + } |
|
78 | 80 | |
79 | 81 | $dim['width'] = round($img->getWidth() / $ratio); |
80 | 82 | $dim['height'] = round($img->getHeight() / $ratio); |
83 | + } else { |
|
84 | + throw new WideImage_Operation_InvalidFitMethodException("{$fit} is not a valid resize-fit method."); |
|
81 | 85 | } |
82 | - else |
|
83 | - throw new WideImage_Operation_InvalidFitMethodException("{$fit} is not a valid resize-fit method."); |
|
84 | 86 | |
85 | 87 | return $dim; |
86 | 88 | } |
@@ -99,11 +101,13 @@ discard block |
||
99 | 101 | { |
100 | 102 | $dim = $this->prepareDimensions($img, $width, $height, $fit); |
101 | 103 | if (($scale === 'down' && ($dim['width'] >= $img->getWidth() && $dim['height'] >= $img->getHeight())) || |
102 | - ($scale === 'up' && ($dim['width'] <= $img->getWidth() && $dim['height'] <= $img->getHeight()))) |
|
103 | - $dim = array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
|
104 | + ($scale === 'up' && ($dim['width'] <= $img->getWidth() && $dim['height'] <= $img->getHeight()))) { |
|
105 | + $dim = array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
|
106 | + } |
|
104 | 107 | |
105 | - if ($dim['width'] <= 0 || $dim['height'] <= 0) |
|
106 | - throw new WideImage_Operation_InvalidResizeDimensionException("Both dimensions must be larger than 0."); |
|
108 | + if ($dim['width'] <= 0 || $dim['height'] <= 0) { |
|
109 | + throw new WideImage_Operation_InvalidResizeDimensionException("Both dimensions must be larger than 0."); |
|
110 | + } |
|
107 | 111 | |
108 | 112 | $new = WideImage_TrueColorImage::create($dim['width'], $dim['height']); |
109 | 113 | |
@@ -119,8 +123,7 @@ discard block |
||
119 | 123 | $img->getWidth(), |
120 | 124 | $img->getHeight() |
121 | 125 | ); |
122 | - } |
|
123 | - else |
|
126 | + } else |
|
124 | 127 | { |
125 | 128 | $new->alphaBlending(false); |
126 | 129 | $new->saveAlpha(true); |