@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,41 +31,41 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class ApplyFilter |
34 | 33 | { |
35 | - /** |
|
36 | - * A list of filters that only accept one arguments for imagefilter() |
|
37 | - * |
|
38 | - * @var array |
|
39 | - */ |
|
40 | - protected static $one_arg_filters = array(IMG_FILTER_SMOOTH, IMG_FILTER_CONTRAST, IMG_FILTER_BRIGHTNESS); |
|
34 | + /** |
|
35 | + * A list of filters that only accept one arguments for imagefilter() |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected static $one_arg_filters = array(IMG_FILTER_SMOOTH, IMG_FILTER_CONTRAST, IMG_FILTER_BRIGHTNESS); |
|
41 | 40 | |
42 | - /** |
|
43 | - * Executes imagefilter |
|
44 | - * |
|
45 | - * @param \WideImage\Image $image |
|
46 | - * @param int $filter |
|
47 | - * @param numeric $arg1 |
|
48 | - * @param numeric $arg2 |
|
49 | - * @param numeric $arg3 |
|
50 | - * @return \WideImage\TrueColorImage |
|
51 | - */ |
|
52 | - public function execute($image, $filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) |
|
53 | - { |
|
54 | - $new = $image->asTrueColor(); |
|
41 | + /** |
|
42 | + * Executes imagefilter |
|
43 | + * |
|
44 | + * @param \WideImage\Image $image |
|
45 | + * @param int $filter |
|
46 | + * @param numeric $arg1 |
|
47 | + * @param numeric $arg2 |
|
48 | + * @param numeric $arg3 |
|
49 | + * @return \WideImage\TrueColorImage |
|
50 | + */ |
|
51 | + public function execute($image, $filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) |
|
52 | + { |
|
53 | + $new = $image->asTrueColor(); |
|
55 | 54 | |
56 | - if (in_array($filter, static::$one_arg_filters)) { |
|
57 | - $res = imagefilter($new->getHandle(), $filter, $arg1); |
|
58 | - } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) { |
|
59 | - $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2); |
|
60 | - } elseif ($filter == IMG_FILTER_COLORIZE) { |
|
61 | - $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); |
|
62 | - } else { |
|
63 | - $res = imagefilter($new->getHandle(), $filter); |
|
64 | - } |
|
55 | + if (in_array($filter, static::$one_arg_filters)) { |
|
56 | + $res = imagefilter($new->getHandle(), $filter, $arg1); |
|
57 | + } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) { |
|
58 | + $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2); |
|
59 | + } elseif ($filter == IMG_FILTER_COLORIZE) { |
|
60 | + $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); |
|
61 | + } else { |
|
62 | + $res = imagefilter($new->getHandle(), $filter); |
|
63 | + } |
|
65 | 64 | |
66 | - if (!$res) { |
|
67 | - throw new GDFunctionResultException("imagefilter() returned false"); |
|
68 | - } |
|
65 | + if (!$res) { |
|
66 | + throw new GDFunctionResultException("imagefilter() returned false"); |
|
67 | + } |
|
69 | 68 | |
70 | - return $new; |
|
71 | - } |
|
69 | + return $new; |
|
70 | + } |
|
72 | 71 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,29 +31,29 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class Flip |
34 | 33 | { |
35 | - /** |
|
36 | - * Returns a flipped image |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @return \WideImage\Image |
|
40 | - */ |
|
41 | - public function execute($image) |
|
42 | - { |
|
43 | - $new = $image->copy(); |
|
34 | + /** |
|
35 | + * Returns a flipped image |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @return \WideImage\Image |
|
39 | + */ |
|
40 | + public function execute($image) |
|
41 | + { |
|
42 | + $new = $image->copy(); |
|
44 | 43 | |
45 | - $width = $image->getWidth(); |
|
46 | - $height = $image->getHeight(); |
|
44 | + $width = $image->getWidth(); |
|
45 | + $height = $image->getHeight(); |
|
47 | 46 | |
48 | - if ($new->isTransparent()) { |
|
49 | - imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor()); |
|
50 | - } |
|
47 | + if ($new->isTransparent()) { |
|
48 | + imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor()); |
|
49 | + } |
|
51 | 50 | |
52 | - for ($y = 0; $y < $height; $y++) { |
|
53 | - if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) { |
|
54 | - throw new GDFunctionResultException("imagecopy() returned false"); |
|
55 | - } |
|
56 | - } |
|
51 | + for ($y = 0; $y < $height; $y++) { |
|
52 | + if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) { |
|
53 | + throw new GDFunctionResultException("imagecopy() returned false"); |
|
54 | + } |
|
55 | + } |
|
57 | 56 | |
58 | - return $new; |
|
59 | - } |
|
57 | + return $new; |
|
58 | + } |
|
60 | 59 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -33,42 +32,42 @@ discard block |
||
33 | 32 | * @package Internal/Operations |
34 | 33 | */ |
35 | 34 | class CopyChannelsTrueColor { |
36 | - /** |
|
37 | - * Returns an image with only specified channels copied |
|
38 | - * |
|
39 | - * @param \WideImage\Image $img |
|
40 | - * @param array $channels |
|
41 | - * @return \WideImage\Image |
|
42 | - */ |
|
43 | - public function execute($img, $channels) |
|
44 | - { |
|
45 | - $blank = array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0); |
|
35 | + /** |
|
36 | + * Returns an image with only specified channels copied |
|
37 | + * |
|
38 | + * @param \WideImage\Image $img |
|
39 | + * @param array $channels |
|
40 | + * @return \WideImage\Image |
|
41 | + */ |
|
42 | + public function execute($img, $channels) |
|
43 | + { |
|
44 | + $blank = array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0); |
|
46 | 45 | |
47 | - $width = $img->getWidth(); |
|
48 | - $height = $img->getHeight(); |
|
49 | - $copy = TrueColorImage::create($width, $height); |
|
46 | + $width = $img->getWidth(); |
|
47 | + $height = $img->getHeight(); |
|
48 | + $copy = TrueColorImage::create($width, $height); |
|
50 | 49 | |
51 | - if (count($channels) > 0) { |
|
52 | - for ($x = 0; $x < $width; $x++) { |
|
53 | - for ($y = 0; $y < $height; $y++) { |
|
54 | - $RGBA = $img->getRGBAt($x, $y); |
|
55 | - $newRGBA = $blank; |
|
50 | + if (count($channels) > 0) { |
|
51 | + for ($x = 0; $x < $width; $x++) { |
|
52 | + for ($y = 0; $y < $height; $y++) { |
|
53 | + $RGBA = $img->getRGBAt($x, $y); |
|
54 | + $newRGBA = $blank; |
|
56 | 55 | |
57 | - foreach ($channels as $channel) { |
|
58 | - $newRGBA[$channel] = $RGBA[$channel]; |
|
59 | - } |
|
56 | + foreach ($channels as $channel) { |
|
57 | + $newRGBA[$channel] = $RGBA[$channel]; |
|
58 | + } |
|
60 | 59 | |
61 | - $color = $copy->getExactColorAlpha($newRGBA); |
|
60 | + $color = $copy->getExactColorAlpha($newRGBA); |
|
62 | 61 | |
63 | - if ($color == -1) { |
|
64 | - $color = $copy->allocateColorAlpha($newRGBA); |
|
65 | - } |
|
62 | + if ($color == -1) { |
|
63 | + $color = $copy->allocateColorAlpha($newRGBA); |
|
64 | + } |
|
66 | 65 | |
67 | - $copy->setColorAt($x, $y, $color); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
66 | + $copy->setColorAt($x, $y, $color); |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
71 | 70 | |
72 | - return $copy; |
|
73 | - } |
|
71 | + return $copy; |
|
72 | + } |
|
74 | 73 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,40 +31,40 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class Rotate |
34 | 33 | { |
35 | - /** |
|
36 | - * Returns rotated image |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @param numeric $angle |
|
40 | - * @param int $bgColor |
|
41 | - * @param bool $ignoreTransparent |
|
42 | - * @return \WideImage\Image |
|
43 | - */ |
|
44 | - public function execute($image, $angle, $bgColor, $ignoreTransparent) |
|
45 | - { |
|
46 | - $angle = -floatval($angle); |
|
34 | + /** |
|
35 | + * Returns rotated image |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @param numeric $angle |
|
39 | + * @param int $bgColor |
|
40 | + * @param bool $ignoreTransparent |
|
41 | + * @return \WideImage\Image |
|
42 | + */ |
|
43 | + public function execute($image, $angle, $bgColor, $ignoreTransparent) |
|
44 | + { |
|
45 | + $angle = -floatval($angle); |
|
47 | 46 | |
48 | - if ($angle < 0) { |
|
49 | - $angle = 360 + $angle; |
|
50 | - } |
|
47 | + if ($angle < 0) { |
|
48 | + $angle = 360 + $angle; |
|
49 | + } |
|
51 | 50 | |
52 | - $angle = $angle % 360; |
|
51 | + $angle = $angle % 360; |
|
53 | 52 | |
54 | - if ($angle == 0) { |
|
55 | - return $image->copy(); |
|
56 | - } |
|
53 | + if ($angle == 0) { |
|
54 | + return $image->copy(); |
|
55 | + } |
|
57 | 56 | |
58 | - $image = $image->asTrueColor(); |
|
57 | + $image = $image->asTrueColor(); |
|
59 | 58 | |
60 | - if ($bgColor === null) { |
|
61 | - $bgColor = $image->getTransparentColor(); |
|
59 | + if ($bgColor === null) { |
|
60 | + $bgColor = $image->getTransparentColor(); |
|
62 | 61 | |
63 | - if ($bgColor == -1) { |
|
64 | - $bgColor = $image->allocateColorAlpha(255, 255, 255, 127); |
|
65 | - imagecolortransparent($image->getHandle(), $bgColor); |
|
66 | - } |
|
67 | - } |
|
62 | + if ($bgColor == -1) { |
|
63 | + $bgColor = $image->allocateColorAlpha(255, 255, 255, 127); |
|
64 | + imagecolortransparent($image->getHandle(), $bgColor); |
|
65 | + } |
|
66 | + } |
|
68 | 67 | |
69 | - return new TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent)); |
|
70 | - } |
|
68 | + return new TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent)); |
|
69 | + } |
|
71 | 70 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -37,130 +36,130 @@ discard block |
||
37 | 36 | */ |
38 | 37 | class Resize |
39 | 38 | { |
40 | - /** |
|
41 | - * Prepares and corrects smart coordinates |
|
42 | - * |
|
43 | - * @param \WideImage\Image $img |
|
44 | - * @param smart_coordinate $width |
|
45 | - * @param smart_coordinate $height |
|
46 | - * @param string $fit |
|
47 | - * @return array |
|
48 | - */ |
|
49 | - protected function prepareDimensions($img, $width, $height, $fit) |
|
50 | - { |
|
51 | - if ($width === null && $height === null) { |
|
52 | - return array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
|
53 | - } |
|
54 | - |
|
55 | - if ($width !== null) { |
|
56 | - $width = Coordinate::fix($width, $img->getWidth()); |
|
57 | - $rx = $img->getWidth() / $width; |
|
58 | - } else { |
|
59 | - $rx = null; |
|
60 | - } |
|
61 | - |
|
62 | - if ($height !== null) { |
|
63 | - $height = Coordinate::fix($height, $img->getHeight()); |
|
64 | - $ry = $img->getHeight() / $height; |
|
65 | - } else { |
|
66 | - $ry = null; |
|
67 | - } |
|
68 | - |
|
69 | - if ($rx === null && $ry !== null) { |
|
70 | - $rx = $ry; |
|
71 | - $width = round($img->getWidth() / $rx); |
|
72 | - } |
|
73 | - |
|
74 | - if ($ry === null && $rx !== null) { |
|
75 | - $ry = $rx; |
|
76 | - $height = round($img->getHeight() / $ry); |
|
77 | - } |
|
78 | - |
|
79 | - if ($width === 0 || $height === 0) { |
|
80 | - return array('width' => 0, 'height' => 0); |
|
81 | - } |
|
82 | - |
|
83 | - if ($fit == null) { |
|
84 | - $fit = 'inside'; |
|
85 | - } |
|
86 | - |
|
87 | - $dim = array(); |
|
88 | - |
|
89 | - if ($fit == 'fill') { |
|
90 | - $dim['width'] = $width; |
|
91 | - $dim['height'] = $height; |
|
92 | - } elseif ($fit == 'inside' || $fit == 'outside') { |
|
93 | - if ($fit == 'inside') { |
|
94 | - $ratio = ($rx > $ry) ? $rx : $ry; |
|
95 | - } else { |
|
96 | - $ratio = ($rx < $ry) ? $rx : $ry; |
|
97 | - } |
|
39 | + /** |
|
40 | + * Prepares and corrects smart coordinates |
|
41 | + * |
|
42 | + * @param \WideImage\Image $img |
|
43 | + * @param smart_coordinate $width |
|
44 | + * @param smart_coordinate $height |
|
45 | + * @param string $fit |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + protected function prepareDimensions($img, $width, $height, $fit) |
|
49 | + { |
|
50 | + if ($width === null && $height === null) { |
|
51 | + return array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
|
52 | + } |
|
53 | + |
|
54 | + if ($width !== null) { |
|
55 | + $width = Coordinate::fix($width, $img->getWidth()); |
|
56 | + $rx = $img->getWidth() / $width; |
|
57 | + } else { |
|
58 | + $rx = null; |
|
59 | + } |
|
60 | + |
|
61 | + if ($height !== null) { |
|
62 | + $height = Coordinate::fix($height, $img->getHeight()); |
|
63 | + $ry = $img->getHeight() / $height; |
|
64 | + } else { |
|
65 | + $ry = null; |
|
66 | + } |
|
67 | + |
|
68 | + if ($rx === null && $ry !== null) { |
|
69 | + $rx = $ry; |
|
70 | + $width = round($img->getWidth() / $rx); |
|
71 | + } |
|
72 | + |
|
73 | + if ($ry === null && $rx !== null) { |
|
74 | + $ry = $rx; |
|
75 | + $height = round($img->getHeight() / $ry); |
|
76 | + } |
|
77 | + |
|
78 | + if ($width === 0 || $height === 0) { |
|
79 | + return array('width' => 0, 'height' => 0); |
|
80 | + } |
|
81 | + |
|
82 | + if ($fit == null) { |
|
83 | + $fit = 'inside'; |
|
84 | + } |
|
85 | + |
|
86 | + $dim = array(); |
|
87 | + |
|
88 | + if ($fit == 'fill') { |
|
89 | + $dim['width'] = $width; |
|
90 | + $dim['height'] = $height; |
|
91 | + } elseif ($fit == 'inside' || $fit == 'outside') { |
|
92 | + if ($fit == 'inside') { |
|
93 | + $ratio = ($rx > $ry) ? $rx : $ry; |
|
94 | + } else { |
|
95 | + $ratio = ($rx < $ry) ? $rx : $ry; |
|
96 | + } |
|
98 | 97 | |
99 | - $dim['width'] = round($img->getWidth() / $ratio); |
|
100 | - $dim['height'] = round($img->getHeight() / $ratio); |
|
101 | - } else { |
|
102 | - throw new InvalidFitMethodException("{$fit} is not a valid resize-fit method."); |
|
103 | - } |
|
104 | - |
|
105 | - return $dim; |
|
106 | - } |
|
98 | + $dim['width'] = round($img->getWidth() / $ratio); |
|
99 | + $dim['height'] = round($img->getHeight() / $ratio); |
|
100 | + } else { |
|
101 | + throw new InvalidFitMethodException("{$fit} is not a valid resize-fit method."); |
|
102 | + } |
|
103 | + |
|
104 | + return $dim; |
|
105 | + } |
|
107 | 106 | |
108 | - /** |
|
109 | - * Returns a resized image |
|
110 | - * |
|
111 | - * @param \WideImage\Image $img |
|
112 | - * @param smart_coordinate $width |
|
113 | - * @param smart_coordinate $height |
|
114 | - * @param string $fit |
|
115 | - * @param string $scale |
|
116 | - * @return \WideImage\Image |
|
117 | - */ |
|
118 | - public function execute($img, $width, $height, $fit, $scale) |
|
119 | - { |
|
120 | - $dim = $this->prepareDimensions($img, $width, $height, $fit); |
|
121 | - |
|
122 | - if (($scale === 'down' && ($dim['width'] >= $img->getWidth() && $dim['height'] >= $img->getHeight())) || |
|
123 | - ($scale === 'up' && ($dim['width'] <= $img->getWidth() && $dim['height'] <= $img->getHeight()))) { |
|
124 | - $dim = array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
|
125 | - } |
|
126 | - |
|
127 | - if ($dim['width'] <= 0 || $dim['height'] <= 0) { |
|
128 | - throw new InvalidResizeDimensionException("Both dimensions must be larger than 0."); |
|
129 | - } |
|
130 | - |
|
131 | - if ($img->isTransparent() || $img instanceof PaletteImage) { |
|
132 | - $new = PaletteImage::create($dim['width'], $dim['height']); |
|
133 | - $new->copyTransparencyFrom($img); |
|
107 | + /** |
|
108 | + * Returns a resized image |
|
109 | + * |
|
110 | + * @param \WideImage\Image $img |
|
111 | + * @param smart_coordinate $width |
|
112 | + * @param smart_coordinate $height |
|
113 | + * @param string $fit |
|
114 | + * @param string $scale |
|
115 | + * @return \WideImage\Image |
|
116 | + */ |
|
117 | + public function execute($img, $width, $height, $fit, $scale) |
|
118 | + { |
|
119 | + $dim = $this->prepareDimensions($img, $width, $height, $fit); |
|
120 | + |
|
121 | + if (($scale === 'down' && ($dim['width'] >= $img->getWidth() && $dim['height'] >= $img->getHeight())) || |
|
122 | + ($scale === 'up' && ($dim['width'] <= $img->getWidth() && $dim['height'] <= $img->getHeight()))) { |
|
123 | + $dim = array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
|
124 | + } |
|
125 | + |
|
126 | + if ($dim['width'] <= 0 || $dim['height'] <= 0) { |
|
127 | + throw new InvalidResizeDimensionException("Both dimensions must be larger than 0."); |
|
128 | + } |
|
129 | + |
|
130 | + if ($img->isTransparent() || $img instanceof PaletteImage) { |
|
131 | + $new = PaletteImage::create($dim['width'], $dim['height']); |
|
132 | + $new->copyTransparencyFrom($img); |
|
134 | 133 | |
135 | - if (!imagecopyresized( |
|
136 | - $new->getHandle(), |
|
137 | - $img->getHandle(), |
|
138 | - 0, 0, 0, 0, |
|
139 | - $new->getWidth(), |
|
140 | - $new->getHeight(), |
|
141 | - $img->getWidth(), |
|
142 | - $img->getHeight())) { |
|
143 | - throw new GDFunctionResultException("imagecopyresized() returned false"); |
|
144 | - } |
|
145 | - } else { |
|
146 | - $new = TrueColorImage::create($dim['width'], $dim['height']); |
|
147 | - $new->alphaBlending(false); |
|
148 | - $new->saveAlpha(true); |
|
134 | + if (!imagecopyresized( |
|
135 | + $new->getHandle(), |
|
136 | + $img->getHandle(), |
|
137 | + 0, 0, 0, 0, |
|
138 | + $new->getWidth(), |
|
139 | + $new->getHeight(), |
|
140 | + $img->getWidth(), |
|
141 | + $img->getHeight())) { |
|
142 | + throw new GDFunctionResultException("imagecopyresized() returned false"); |
|
143 | + } |
|
144 | + } else { |
|
145 | + $new = TrueColorImage::create($dim['width'], $dim['height']); |
|
146 | + $new->alphaBlending(false); |
|
147 | + $new->saveAlpha(true); |
|
149 | 148 | |
150 | - if (!imagecopyresampled( |
|
151 | - $new->getHandle(), |
|
152 | - $img->getHandle(), |
|
153 | - 0, 0, 0, 0, |
|
154 | - $new->getWidth(), |
|
155 | - $new->getHeight(), |
|
156 | - $img->getWidth(), |
|
157 | - $img->getHeight())) { |
|
158 | - throw new GDFunctionResultException("imagecopyresampled() returned false"); |
|
159 | - } |
|
149 | + if (!imagecopyresampled( |
|
150 | + $new->getHandle(), |
|
151 | + $img->getHandle(), |
|
152 | + 0, 0, 0, 0, |
|
153 | + $new->getWidth(), |
|
154 | + $new->getHeight(), |
|
155 | + $img->getWidth(), |
|
156 | + $img->getHeight())) { |
|
157 | + throw new GDFunctionResultException("imagecopyresampled() returned false"); |
|
158 | + } |
|
160 | 159 | |
161 | - $new->alphaBlending(true); |
|
162 | - } |
|
160 | + $new->alphaBlending(true); |
|
161 | + } |
|
163 | 162 | |
164 | - return $new; |
|
165 | - } |
|
163 | + return $new; |
|
164 | + } |
|
166 | 165 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,93 +31,93 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class RoundCorners |
34 | 33 | { |
35 | - /** |
|
36 | - * @param \WideImage\Image $image |
|
37 | - * @param int $radius |
|
38 | - * @param int $color |
|
39 | - * @param int $smoothness |
|
40 | - * @return \WideImage\Image |
|
41 | - */ |
|
42 | - public function execute($image, $radius, $color, $smoothness, $corners) |
|
43 | - { |
|
44 | - if ($smoothness < 1) { |
|
45 | - $sample_ratio = 1; |
|
46 | - } elseif ($smoothness > 16) { |
|
47 | - $sample_ratio = 16; |
|
48 | - } else { |
|
49 | - $sample_ratio = $smoothness; |
|
50 | - } |
|
34 | + /** |
|
35 | + * @param \WideImage\Image $image |
|
36 | + * @param int $radius |
|
37 | + * @param int $color |
|
38 | + * @param int $smoothness |
|
39 | + * @return \WideImage\Image |
|
40 | + */ |
|
41 | + public function execute($image, $radius, $color, $smoothness, $corners) |
|
42 | + { |
|
43 | + if ($smoothness < 1) { |
|
44 | + $sample_ratio = 1; |
|
45 | + } elseif ($smoothness > 16) { |
|
46 | + $sample_ratio = 16; |
|
47 | + } else { |
|
48 | + $sample_ratio = $smoothness; |
|
49 | + } |
|
51 | 50 | |
52 | - $corner = WideImage::createTrueColorImage($radius * $sample_ratio, $radius * $sample_ratio); |
|
51 | + $corner = WideImage::createTrueColorImage($radius * $sample_ratio, $radius * $sample_ratio); |
|
53 | 52 | |
54 | - if ($color === null) { |
|
55 | - imagepalettecopy($corner->getHandle(), $image->getHandle()); |
|
56 | - $bg_color = $corner->allocateColor(0, 0, 0); |
|
53 | + if ($color === null) { |
|
54 | + imagepalettecopy($corner->getHandle(), $image->getHandle()); |
|
55 | + $bg_color = $corner->allocateColor(0, 0, 0); |
|
57 | 56 | |
58 | - $corner->fill(0, 0, $bg_color); |
|
59 | - $fg_color = $corner->allocateColor(255, 255, 255); |
|
60 | - $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color); |
|
61 | - $corner = $corner->resize($radius, $radius); |
|
57 | + $corner->fill(0, 0, $bg_color); |
|
58 | + $fg_color = $corner->allocateColor(255, 255, 255); |
|
59 | + $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color); |
|
60 | + $corner = $corner->resize($radius, $radius); |
|
62 | 61 | |
63 | - $result = $image->asTrueColor(); |
|
62 | + $result = $image->asTrueColor(); |
|
64 | 63 | |
65 | - $tc = $result->getTransparentColor(); |
|
64 | + $tc = $result->getTransparentColor(); |
|
66 | 65 | |
67 | - if ($tc == -1) { |
|
68 | - $tc = $result->allocateColorAlpha(255, 255, 255, 127); |
|
69 | - imagecolortransparent($result->getHandle(), $tc); |
|
70 | - $result->setTransparentColor($tc); |
|
71 | - } |
|
66 | + if ($tc == -1) { |
|
67 | + $tc = $result->allocateColorAlpha(255, 255, 255, 127); |
|
68 | + imagecolortransparent($result->getHandle(), $tc); |
|
69 | + $result->setTransparentColor($tc); |
|
70 | + } |
|
72 | 71 | |
73 | - if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) { |
|
74 | - $result = $result->applyMask($corner, -1, -1); |
|
75 | - } |
|
72 | + if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) { |
|
73 | + $result = $result->applyMask($corner, -1, -1); |
|
74 | + } |
|
76 | 75 | |
77 | - $corner = $corner->rotate(90); |
|
78 | - if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) { |
|
79 | - $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100); |
|
80 | - } |
|
76 | + $corner = $corner->rotate(90); |
|
77 | + if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) { |
|
78 | + $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100); |
|
79 | + } |
|
81 | 80 | |
82 | - $corner = $corner->rotate(90); |
|
83 | - if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) { |
|
84 | - $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
85 | - } |
|
81 | + $corner = $corner->rotate(90); |
|
82 | + if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) { |
|
83 | + $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
84 | + } |
|
86 | 85 | |
87 | - $corner = $corner->rotate(90); |
|
88 | - if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) { |
|
89 | - $result = $result->applyMask($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
90 | - } |
|
86 | + $corner = $corner->rotate(90); |
|
87 | + if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) { |
|
88 | + $result = $result->applyMask($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
89 | + } |
|
91 | 90 | |
92 | - return $result; |
|
93 | - } else { |
|
94 | - $bg_color = $color; |
|
91 | + return $result; |
|
92 | + } else { |
|
93 | + $bg_color = $color; |
|
95 | 94 | |
96 | - $corner->fill(0, 0, $bg_color); |
|
97 | - $fg_color = $corner->allocateColorAlpha(127, 127, 127, 127); |
|
98 | - $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color); |
|
99 | - $corner = $corner->resize($radius, $radius); |
|
95 | + $corner->fill(0, 0, $bg_color); |
|
96 | + $fg_color = $corner->allocateColorAlpha(127, 127, 127, 127); |
|
97 | + $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color); |
|
98 | + $corner = $corner->resize($radius, $radius); |
|
100 | 99 | |
101 | - $result = $image->copy(); |
|
102 | - if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) { |
|
103 | - $result = $result->merge($corner, -1, -1, 100); |
|
104 | - } |
|
100 | + $result = $image->copy(); |
|
101 | + if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) { |
|
102 | + $result = $result->merge($corner, -1, -1, 100); |
|
103 | + } |
|
105 | 104 | |
106 | - $corner = $corner->rotate(90); |
|
107 | - if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) { |
|
108 | - $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100); |
|
109 | - } |
|
105 | + $corner = $corner->rotate(90); |
|
106 | + if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) { |
|
107 | + $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100); |
|
108 | + } |
|
110 | 109 | |
111 | - $corner = $corner->rotate(90); |
|
112 | - if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) { |
|
113 | - $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
114 | - } |
|
110 | + $corner = $corner->rotate(90); |
|
111 | + if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) { |
|
112 | + $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
113 | + } |
|
115 | 114 | |
116 | - $corner = $corner->rotate(90); |
|
117 | - if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) { |
|
118 | - $result = $result->merge($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
119 | - } |
|
115 | + $corner = $corner->rotate(90); |
|
116 | + if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) { |
|
117 | + $result = $result->merge($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100); |
|
118 | + } |
|
120 | 119 | |
121 | - return $result; |
|
122 | - } |
|
123 | - } |
|
120 | + return $result; |
|
121 | + } |
|
122 | + } |
|
124 | 123 | } |
@@ -18,7 +18,6 @@ |
||
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 | 21 | * @package WideImage |
23 | 22 | **/ |
24 | 23 |
@@ -18,7 +18,6 @@ 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 | 21 | * @package WideImage |
23 | 22 | **/ |
24 | 23 | |
@@ -34,99 +33,99 @@ discard block |
||
34 | 33 | **/ |
35 | 34 | abstract class MapperFactory |
36 | 35 | { |
37 | - static protected $mappers = array(); |
|
38 | - static protected $customMappers = array(); |
|
36 | + static protected $mappers = array(); |
|
37 | + static protected $customMappers = array(); |
|
39 | 38 | |
40 | - static protected $mimeTable = array( |
|
41 | - 'image/jpg' => 'JPEG', |
|
42 | - 'image/jpeg' => 'JPEG', |
|
43 | - 'image/pjpeg' => 'JPEG', |
|
44 | - 'image/gif' => 'GIF', |
|
45 | - 'image/png' => 'PNG', |
|
46 | - 'image/webp' => 'WEBP' |
|
47 | - ); |
|
39 | + static protected $mimeTable = array( |
|
40 | + 'image/jpg' => 'JPEG', |
|
41 | + 'image/jpeg' => 'JPEG', |
|
42 | + 'image/pjpeg' => 'JPEG', |
|
43 | + 'image/gif' => 'GIF', |
|
44 | + 'image/png' => 'PNG', |
|
45 | + 'image/webp' => 'WEBP' |
|
46 | + ); |
|
48 | 47 | |
49 | - /** |
|
50 | - * Returns a mapper, based on the $uri and $format |
|
51 | - * |
|
52 | - * @param string $uri File URI |
|
53 | - * @param string $format File format (extension or mime-type) or null |
|
54 | - * @return mixed |
|
55 | - **/ |
|
56 | - public static function selectMapper($uri, $format = null) |
|
57 | - { |
|
58 | - $format = self::determineFormat($uri, $format); |
|
48 | + /** |
|
49 | + * Returns a mapper, based on the $uri and $format |
|
50 | + * |
|
51 | + * @param string $uri File URI |
|
52 | + * @param string $format File format (extension or mime-type) or null |
|
53 | + * @return mixed |
|
54 | + **/ |
|
55 | + public static function selectMapper($uri, $format = null) |
|
56 | + { |
|
57 | + $format = self::determineFormat($uri, $format); |
|
59 | 58 | |
60 | - if (array_key_exists($format, self::$mappers)) { |
|
61 | - return self::$mappers[$format]; |
|
62 | - } |
|
59 | + if (array_key_exists($format, self::$mappers)) { |
|
60 | + return self::$mappers[$format]; |
|
61 | + } |
|
63 | 62 | |
64 | - $mapperClassName = '\\WideImage\\Mapper\\' . $format; |
|
63 | + $mapperClassName = '\\WideImage\\Mapper\\' . $format; |
|
65 | 64 | |
66 | - // why not use autoloading? |
|
67 | - // if (!class_exists($mapperClassName, false)) { |
|
68 | - if (!class_exists($mapperClassName)) { |
|
69 | - throw new UnsupportedFormatException("Format '{$format}' is not supported."); |
|
70 | - } |
|
65 | + // why not use autoloading? |
|
66 | + // if (!class_exists($mapperClassName, false)) { |
|
67 | + if (!class_exists($mapperClassName)) { |
|
68 | + throw new UnsupportedFormatException("Format '{$format}' is not supported."); |
|
69 | + } |
|
71 | 70 | |
72 | - if (class_exists($mapperClassName)) { |
|
73 | - self::$mappers[$format] = new $mapperClassName(); |
|
74 | - return self::$mappers[$format]; |
|
75 | - } |
|
76 | - } |
|
71 | + if (class_exists($mapperClassName)) { |
|
72 | + self::$mappers[$format] = new $mapperClassName(); |
|
73 | + return self::$mappers[$format]; |
|
74 | + } |
|
75 | + } |
|
77 | 76 | |
78 | - public static function registerMapper($mapper_class_name, $mime_type, $extension) |
|
79 | - { |
|
80 | - self::$customMappers[$mime_type] = $mapper_class_name; |
|
81 | - self::$mimeTable[$mime_type] = $extension; |
|
82 | - } |
|
77 | + public static function registerMapper($mapper_class_name, $mime_type, $extension) |
|
78 | + { |
|
79 | + self::$customMappers[$mime_type] = $mapper_class_name; |
|
80 | + self::$mimeTable[$mime_type] = $extension; |
|
81 | + } |
|
83 | 82 | |
84 | - public static function getCustomMappers() |
|
85 | - { |
|
86 | - return self::$customMappers; |
|
87 | - } |
|
83 | + public static function getCustomMappers() |
|
84 | + { |
|
85 | + return self::$customMappers; |
|
86 | + } |
|
88 | 87 | |
89 | - public static function determineFormat($uri, $format = null) |
|
90 | - { |
|
91 | - if ($format == null) { |
|
92 | - $format = self::extractExtension($uri); |
|
93 | - } |
|
88 | + public static function determineFormat($uri, $format = null) |
|
89 | + { |
|
90 | + if ($format == null) { |
|
91 | + $format = self::extractExtension($uri); |
|
92 | + } |
|
94 | 93 | |
95 | - // mime-type match |
|
96 | - if (preg_match('~[a-z]*/[a-z-]*~i', $format)) { |
|
97 | - if (isset(self::$mimeTable[strtolower($format)])) { |
|
98 | - return self::$mimeTable[strtolower($format)]; |
|
99 | - } |
|
100 | - } |
|
94 | + // mime-type match |
|
95 | + if (preg_match('~[a-z]*/[a-z-]*~i', $format)) { |
|
96 | + if (isset(self::$mimeTable[strtolower($format)])) { |
|
97 | + return self::$mimeTable[strtolower($format)]; |
|
98 | + } |
|
99 | + } |
|
101 | 100 | |
102 | - // clean the string |
|
103 | - $format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format)); |
|
104 | - if ($format == 'JPG') { |
|
105 | - $format = 'JPEG'; |
|
106 | - } |
|
101 | + // clean the string |
|
102 | + $format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format)); |
|
103 | + if ($format == 'JPG') { |
|
104 | + $format = 'JPEG'; |
|
105 | + } |
|
107 | 106 | |
108 | - return $format; |
|
109 | - } |
|
107 | + return $format; |
|
108 | + } |
|
110 | 109 | |
111 | - public static function mimeType($format) |
|
112 | - { |
|
113 | - $format = strtoupper($format); |
|
110 | + public static function mimeType($format) |
|
111 | + { |
|
112 | + $format = strtoupper($format); |
|
114 | 113 | |
115 | - if ($format == 'JPG') { |
|
116 | - $format = 'JPEG'; |
|
117 | - } |
|
114 | + if ($format == 'JPG') { |
|
115 | + $format = 'JPEG'; |
|
116 | + } |
|
118 | 117 | |
119 | - return array_search($format, self::$mimeTable); |
|
120 | - } |
|
118 | + return array_search($format, self::$mimeTable); |
|
119 | + } |
|
121 | 120 | |
122 | - public static function extractExtension($uri) |
|
123 | - { |
|
124 | - $p = strrpos($uri, '.'); |
|
121 | + public static function extractExtension($uri) |
|
122 | + { |
|
123 | + $p = strrpos($uri, '.'); |
|
125 | 124 | |
126 | - if ($p === false) { |
|
127 | - return ''; |
|
128 | - } |
|
125 | + if ($p === false) { |
|
126 | + return ''; |
|
127 | + } |
|
129 | 128 | |
130 | - return substr($uri, $p + 1); |
|
131 | - } |
|
129 | + return substr($uri, $p + 1); |
|
130 | + } |
|
132 | 131 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | return self::$mappers[$format]; |
62 | 62 | } |
63 | 63 | |
64 | - $mapperClassName = '\\WideImage\\Mapper\\' . $format; |
|
64 | + $mapperClassName = '\\WideImage\\Mapper\\'.$format; |
|
65 | 65 | |
66 | 66 | // why not use autoloading? |
67 | 67 | // if (!class_exists($mapperClassName, false)) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internals |
|
22 | - **/ |
|
20 | + * @package Internals |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage; |
25 | 24 | |
@@ -33,24 +32,24 @@ discard block |
||
33 | 32 | **/ |
34 | 33 | class OperationFactory |
35 | 34 | { |
36 | - protected static $cache = array(); |
|
35 | + protected static $cache = array(); |
|
37 | 36 | |
38 | - public static function get($operationName) |
|
39 | - { |
|
40 | - $lcname = strtolower($operationName); |
|
37 | + public static function get($operationName) |
|
38 | + { |
|
39 | + $lcname = strtolower($operationName); |
|
41 | 40 | |
42 | - if (!isset(self::$cache[$lcname])) { |
|
43 | - $opClassName = "\\WideImage\\Operation\\" . ucfirst($operationName); |
|
41 | + if (!isset(self::$cache[$lcname])) { |
|
42 | + $opClassName = "\\WideImage\\Operation\\" . ucfirst($operationName); |
|
44 | 43 | |
45 | - // why not use autoloading? |
|
46 | - // if (!class_exists($opClassName, false)) { |
|
47 | - if (!class_exists($opClassName)) { |
|
48 | - throw new UnknownImageOperationException("Can't load '{$operationName}' operation."); |
|
49 | - } |
|
44 | + // why not use autoloading? |
|
45 | + // if (!class_exists($opClassName, false)) { |
|
46 | + if (!class_exists($opClassName)) { |
|
47 | + throw new UnknownImageOperationException("Can't load '{$operationName}' operation."); |
|
48 | + } |
|
50 | 49 | |
51 | - self::$cache[$lcname] = new $opClassName(); |
|
52 | - } |
|
50 | + self::$cache[$lcname] = new $opClassName(); |
|
51 | + } |
|
53 | 52 | |
54 | - return self::$cache[$lcname]; |
|
55 | - } |
|
53 | + return self::$cache[$lcname]; |
|
54 | + } |
|
56 | 55 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | $lcname = strtolower($operationName); |
41 | 41 | |
42 | 42 | if (!isset(self::$cache[$lcname])) { |
43 | - $opClassName = "\\WideImage\\Operation\\" . ucfirst($operationName); |
|
43 | + $opClassName = "\\WideImage\\Operation\\".ucfirst($operationName); |
|
44 | 44 | |
45 | 45 | // why not use autoloading? |
46 | 46 | // if (!class_exists($opClassName, false)) { |