Test Failed
Push — master ( 398493...d4ef72 )
by Michael
11:04
created
libraries/vendor/smottt/wideimage/lib/WideImage/Operation/RoundCorners.php 1 patch
Indentation   +75 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/Operation/Unsharp.php 1 patch
Indentation   +100 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -34,121 +33,121 @@  discard block
 block discarded – undo
34 33
  */
35 34
 class Unsharp
36 35
 {
37
-	/**
38
-	 * Returns sharpened image
39
-	 *
40
-	 * @param \WideImage\Image $image
41
-	 * @param float $amount
42
-	 * @param int $radius
43
-	 * @param float $threshold
44
-	 * @return \WideImage\Image
45
-	 */
46
-	public function execute($image, $amount, $radius, $threshold)
47
-	{
48
-		// Attempt to calibrate the parameters to Photoshop:
49
-		if ($amount > 500) {
50
-			$amount = 500;
51
-		}
36
+    /**
37
+     * Returns sharpened image
38
+     *
39
+     * @param \WideImage\Image $image
40
+     * @param float $amount
41
+     * @param int $radius
42
+     * @param float $threshold
43
+     * @return \WideImage\Image
44
+     */
45
+    public function execute($image, $amount, $radius, $threshold)
46
+    {
47
+        // Attempt to calibrate the parameters to Photoshop:
48
+        if ($amount > 500) {
49
+            $amount = 500;
50
+        }
52 51
 		
53
-		$amount = $amount * 0.016;
52
+        $amount = $amount * 0.016;
54 53
 		
55
-		if ($radius > 50) {
56
-			$radius = 50;
57
-		}
54
+        if ($radius > 50) {
55
+            $radius = 50;
56
+        }
58 57
 		
59
-		$radius = $radius * 2;
58
+        $radius = $radius * 2;
60 59
 		
61
-		if ($threshold > 255) {
62
-			$threshold = 255;
63
-		}
60
+        if ($threshold > 255) {
61
+            $threshold = 255;
62
+        }
64 63
 		
65
-		$radius = abs(round($radius)); // Only integers make sense.
64
+        $radius = abs(round($radius)); // Only integers make sense.
66 65
 		
67
-		if ($radius == 0) {
68
-			return $image;
69
-		}
66
+        if ($radius == 0) {
67
+            return $image;
68
+        }
70 69
 		
71
-		// Gaussian blur matrix
72
-		$matrix = array(
73
-			array(1, 2, 1),
74
-			array(2, 4, 2),
75
-			array(1, 2, 1)
76
-		);
70
+        // Gaussian blur matrix
71
+        $matrix = array(
72
+            array(1, 2, 1),
73
+            array(2, 4, 2),
74
+            array(1, 2, 1)
75
+        );
77 76
 		
78
-		$blurred = $image->applyConvolution($matrix, 16, 0);
77
+        $blurred = $image->applyConvolution($matrix, 16, 0);
79 78
 		
80
-		if ($threshold > 0) {
81
-			// Calculate the difference between the blurred pixels and the original
82
-			// and set the pixels
83
-			for ($x = 0; $x < $image->getWidth(); $x++) {
84
-				for ($y = 0; $y < $image->getHeight(); $y++) {
85
-					$rgbOrig = $image->getRGBAt($x, $y);
86
-					$rOrig   = $rgbOrig["red"];
87
-					$gOrig   = $rgbOrig["green"];
88
-					$bOrig   = $rgbOrig["blue"];
79
+        if ($threshold > 0) {
80
+            // Calculate the difference between the blurred pixels and the original
81
+            // and set the pixels
82
+            for ($x = 0; $x < $image->getWidth(); $x++) {
83
+                for ($y = 0; $y < $image->getHeight(); $y++) {
84
+                    $rgbOrig = $image->getRGBAt($x, $y);
85
+                    $rOrig   = $rgbOrig["red"];
86
+                    $gOrig   = $rgbOrig["green"];
87
+                    $bOrig   = $rgbOrig["blue"];
89 88
 					 
90
-					$rgbBlur = $blurred->getRGBAt($x, $y);
91
-					$rBlur   = $rgbBlur["red"];
92
-					$gBlur   = $rgbBlur["green"];
93
-					$bBlur   = $rgbBlur["blue"];
89
+                    $rgbBlur = $blurred->getRGBAt($x, $y);
90
+                    $rBlur   = $rgbBlur["red"];
91
+                    $gBlur   = $rgbBlur["green"];
92
+                    $bBlur   = $rgbBlur["blue"];
94 93
 					
95
-					// When the masked pixels differ less from the original
96
-					// than the threshold specifies, they are set to their original value.
97
-					$rNew = (abs($rOrig - $rBlur) >= $threshold)  
98
-						? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig))  
99
-						: $rOrig;
100
-					$gNew = (abs($gOrig - $gBlur) >= $threshold)  
101
-						? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig))  
102
-						: $gOrig;
103
-					$bNew = (abs($bOrig - $bBlur) >= $threshold)  
104
-						? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig))  
105
-						: $bOrig;
106
-					$rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0);
94
+                    // When the masked pixels differ less from the original
95
+                    // than the threshold specifies, they are set to their original value.
96
+                    $rNew = (abs($rOrig - $rBlur) >= $threshold)  
97
+                        ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig))  
98
+                        : $rOrig;
99
+                    $gNew = (abs($gOrig - $gBlur) >= $threshold)  
100
+                        ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig))  
101
+                        : $gOrig;
102
+                    $bNew = (abs($bOrig - $bBlur) >= $threshold)  
103
+                        ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig))  
104
+                        : $bOrig;
105
+                    $rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0);
107 106
 					
108
-					if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) {
109
-						$image->setRGBAt($x, $y, $rgbNew);
110
-					}
111
-				}
112
-			}
113
-		} else {
114
-			$w = $image->getWidth();
115
-			$h = $image->getHeight();
107
+                    if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) {
108
+                        $image->setRGBAt($x, $y, $rgbNew);
109
+                    }
110
+                }
111
+            }
112
+        } else {
113
+            $w = $image->getWidth();
114
+            $h = $image->getHeight();
116 115
 			
117
-			for ($x = 0; $x < $w; $x++) {
118
-				for ($y = 0; $y < $h; $y++) {
119
-					$rgbOrig = $image->getRGBAt($x, $y);
120
-					$rOrig   = $rgbOrig["red"];
121
-					$gOrig   = $rgbOrig["green"];
122
-					$bOrig   = $rgbOrig["blue"];
116
+            for ($x = 0; $x < $w; $x++) {
117
+                for ($y = 0; $y < $h; $y++) {
118
+                    $rgbOrig = $image->getRGBAt($x, $y);
119
+                    $rOrig   = $rgbOrig["red"];
120
+                    $gOrig   = $rgbOrig["green"];
121
+                    $bOrig   = $rgbOrig["blue"];
123 122
 					
124
-					$rgbBlur = $blurred->getRGBAt($x, $y);
125
-					$rBlur   = $rgbBlur["red"];
126
-					$gBlur   = $rgbBlur["green"];
127
-					$bBlur   = $rgbBlur["blue"];
123
+                    $rgbBlur = $blurred->getRGBAt($x, $y);
124
+                    $rBlur   = $rgbBlur["red"];
125
+                    $gBlur   = $rgbBlur["green"];
126
+                    $bBlur   = $rgbBlur["blue"];
128 127
 					
129
-					$rNew   = static::bit(($amount * ($rOrig - $rBlur)) + $rOrig);
130
-					$gNew   = static::bit(($amount * ($gOrig - $gBlur)) + $gOrig);
131
-					$bNew   = static::bit(($amount * ($bOrig - $bBlur)) + $bOrig);
132
-					$rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0);
128
+                    $rNew   = static::bit(($amount * ($rOrig - $rBlur)) + $rOrig);
129
+                    $gNew   = static::bit(($amount * ($gOrig - $gBlur)) + $gOrig);
130
+                    $bNew   = static::bit(($amount * ($bOrig - $bBlur)) + $bOrig);
131
+                    $rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0);
133 132
 					
134
-					$image->setRGBAt($x, $y, $rgbNew);
135
-				}
136
-			}
137
-		}
133
+                    $image->setRGBAt($x, $y, $rgbNew);
134
+                }
135
+            }
136
+        }
138 137
 		
139
-		return $image;
140
-	}
138
+        return $image;
139
+    }
141 140
 	
142
-	protected static function bit($val)
143
-	{
144
-		if ($val > 255) {
145
-			return 255;
146
-		}
141
+    protected static function bit($val)
142
+    {
143
+        if ($val > 255) {
144
+            return 255;
145
+        }
147 146
 		
148
-		if ($val < 0) {
149
-			return 0;
150
-		}
147
+        if ($val < 0) {
148
+            return 0;
149
+        }
151 150
 		
152
-		return $val;
153
-	}
151
+        return $val;
152
+    }
154 153
 }
Please login to merge, or discard this patch.
libraries/vendor/smottt/wideimage/lib/WideImage/Operation/AsNegative.php 1 patch
Indentation   +31 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,39 +31,39 @@  discard block
 block discarded – undo
32 31
  */
33 32
 class AsNegative
34 33
 {
35
-	/**
36
-	 * Returns a greyscale copy of an image
37
-	 *
38
-	 * @param \WideImage\Image $image
39
-	 * @return \WideImage\Image
40
-	 */
41
-	public function execute($image)
42
-	{
43
-		$palette     = !$image->isTrueColor();
44
-		$transparent = $image->isTransparent();
34
+    /**
35
+     * Returns a greyscale copy of an image
36
+     *
37
+     * @param \WideImage\Image $image
38
+     * @return \WideImage\Image
39
+     */
40
+    public function execute($image)
41
+    {
42
+        $palette     = !$image->isTrueColor();
43
+        $transparent = $image->isTransparent();
45 44
 		
46
-		if ($palette && $transparent) {
47
-			$tcrgb = $image->getTransparentColorRGB();
48
-		}
45
+        if ($palette && $transparent) {
46
+            $tcrgb = $image->getTransparentColorRGB();
47
+        }
49 48
 		
50
-		$new = $image->asTrueColor();
49
+        $new = $image->asTrueColor();
51 50
 		
52
-		if (!imagefilter($new->getHandle(), IMG_FILTER_NEGATE)) {
53
-			throw new GDFunctionResultException("imagefilter() returned false");
54
-		}
51
+        if (!imagefilter($new->getHandle(), IMG_FILTER_NEGATE)) {
52
+            throw new GDFunctionResultException("imagefilter() returned false");
53
+        }
55 54
 		
56
-		if ($palette) {
57
-			$new = $new->asPalette();
55
+        if ($palette) {
56
+            $new = $new->asPalette();
58 57
 			
59
-			if ($transparent) {
60
-				$irgb = array('red' => 255 - $tcrgb['red'], 'green' => 255 - $tcrgb['green'], 'blue' => 255 - $tcrgb['blue'], 'alpha' => 127);
58
+            if ($transparent) {
59
+                $irgb = array('red' => 255 - $tcrgb['red'], 'green' => 255 - $tcrgb['green'], 'blue' => 255 - $tcrgb['blue'], 'alpha' => 127);
61 60
 				
62
-				// needs imagecolorexactalpha instead of imagecolorexact, otherwise doesn't work on some transparent GIF images
63
-				$new_tci = imagecolorexactalpha($new->getHandle(), $irgb['red'], $irgb['green'], $irgb['blue'], 127);
64
-				$new->setTransparentColor($new_tci);
65
-			}
66
-		}
61
+                // needs imagecolorexactalpha instead of imagecolorexact, otherwise doesn't work on some transparent GIF images
62
+                $new_tci = imagecolorexactalpha($new->getHandle(), $irgb['red'], $irgb['green'], $irgb['blue'], 127);
63
+                $new->setTransparentColor($new_tci);
64
+            }
65
+        }
67 66
 		
68
-		return $new;
69
-	}
67
+        return $new;
68
+    }
70 69
 }
Please login to merge, or discard this patch.
libraries/vendor/smottt/wideimage/lib/WideImage/Operation/AddNoise.php 2 patches
Indentation   +123 added lines, -124 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
3
-	* @author Tomasz Kapusta
4
-	* @copyright 2010
2
+    /**
3
+     * @author Tomasz Kapusta
4
+     * @copyright 2010
5 5
 	
6 6
 	This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
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
 namespace WideImage\Operation;
26 25
 
@@ -31,137 +30,137 @@  discard block
 block discarded – undo
31 30
  */
32 31
 class AddNoise
33 32
 {
34
-	/**
35
-	 * Returns image with noise added
36
-	 *
37
-	 * @param \WideImage\Image $image
38
-	 * @param float $amount
39
-	 * @param const $type
40
-	 * @param float $threshold
41
-	 * @return \WideImage\Image
42
-	 */
43
-	public function execute($image, $amount, $type) {
44
-		switch ($type) {
45
-			case 'salt&pepper':
46
-				$fun = 'saltPepperNoise_fun'; 
47
-				break;
48
-			case 'color':
49
-				$fun = 'colorNoise_fun';
50
-				break;	
51
-			default	:
52
-				$fun = 'monoNoise_fun';
53
-				break; 			
54
-		}
33
+    /**
34
+     * Returns image with noise added
35
+     *
36
+     * @param \WideImage\Image $image
37
+     * @param float $amount
38
+     * @param const $type
39
+     * @param float $threshold
40
+     * @return \WideImage\Image
41
+     */
42
+    public function execute($image, $amount, $type) {
43
+        switch ($type) {
44
+            case 'salt&pepper':
45
+                $fun = 'saltPepperNoise_fun'; 
46
+                break;
47
+            case 'color':
48
+                $fun = 'colorNoise_fun';
49
+                break;	
50
+            default	:
51
+                $fun = 'monoNoise_fun';
52
+                break; 			
53
+        }
55 54
 		
56
-		return static::filter($image->asTrueColor(), $fun, $amount);			
57
-	}
55
+        return static::filter($image->asTrueColor(), $fun, $amount);			
56
+    }
58 57
 	
59
-	/**
60
-	 * Returns image with every pixel changed by specififed function
61
-	 *
62
-	 * @param \WideImage\Image $image
63
-	 * @param str $function
64
-	 * @param int $value
65
-	 * @return \WideImage\Image
66
-	 */
67
-	public function filter($image, $function, $value)
68
-	{
69
-		for ($y = 0; $y < $image->getHeight(); $y++) {
70
-	    	for ($x = 0; $x< $image->getWidth(); $x++) {	     
71
-				$rgb = imagecolorat($image->getHandle(), $x, $y);				
58
+    /**
59
+     * Returns image with every pixel changed by specififed function
60
+     *
61
+     * @param \WideImage\Image $image
62
+     * @param str $function
63
+     * @param int $value
64
+     * @return \WideImage\Image
65
+     */
66
+    public function filter($image, $function, $value)
67
+    {
68
+        for ($y = 0; $y < $image->getHeight(); $y++) {
69
+            for ($x = 0; $x< $image->getWidth(); $x++) {	     
70
+                $rgb = imagecolorat($image->getHandle(), $x, $y);				
72 71
 				
73
-				$a = ($rgb >> 24) & 0xFF;
74
-				$r = ($rgb >> 16) & 0xFF;
75
-				$g = ($rgb >> 8) & 0xFF;
76
-				$b = $rgb & 0xFF;
72
+                $a = ($rgb >> 24) & 0xFF;
73
+                $r = ($rgb >> 16) & 0xFF;
74
+                $g = ($rgb >> 8) & 0xFF;
75
+                $b = $rgb & 0xFF;
77 76
 				
78
-				static::$function($r, $g, $b, $value);
77
+                static::$function($r, $g, $b, $value);
79 78
 				
80
-				$color = imagecolorallocatealpha($image->getHandle(), $r, $g, $b, $a);				
81
-				imagesetpixel($image->getHandle(), $x, $y, $color); 
82
-	      	}
83
-	    }
79
+                $color = imagecolorallocatealpha($image->getHandle(), $r, $g, $b, $a);				
80
+                imagesetpixel($image->getHandle(), $x, $y, $color); 
81
+                }
82
+        }
84 83
 	    
85
-	    return $image;
86
-	}
84
+        return $image;
85
+    }
87 86
 	
88
-	/**
89
-	 * Adds color noise by altering given R,G,B values using specififed amount
90
-	 *
91
-	 * @param int $r
92
-	 * @param int $g
93
-	 * @param int $b
94
-	 * @param int $value		 
95
-	 * @return void
96
-	 */
97
-	public function colorNoise_fun(&$r, &$g, &$b, $amount)
98
-	{				
99
-		$r = static::byte($r + mt_rand(0, $amount) - ($amount >> 1) );
100
-		$g = static::byte($g + mt_rand(0, $amount) - ($amount >> 1) );
101
-		$b = static::byte($b + mt_rand(0, $amount) - ($amount >> 1) );
102
-	}
87
+    /**
88
+     * Adds color noise by altering given R,G,B values using specififed amount
89
+     *
90
+     * @param int $r
91
+     * @param int $g
92
+     * @param int $b
93
+     * @param int $value		 
94
+     * @return void
95
+     */
96
+    public function colorNoise_fun(&$r, &$g, &$b, $amount)
97
+    {				
98
+        $r = static::byte($r + mt_rand(0, $amount) - ($amount >> 1) );
99
+        $g = static::byte($g + mt_rand(0, $amount) - ($amount >> 1) );
100
+        $b = static::byte($b + mt_rand(0, $amount) - ($amount >> 1) );
101
+    }
103 102
 	
104
-	/**
105
-	 * Adds mono noise by altering given R,G,B values using specififed amount
106
-	 *
107
-	 * @param int $r
108
-	 * @param int $g
109
-	 * @param int $b
110
-	 * @param int $value		 
111
-	 * @return void
112
-	 */
113
-	public function monoNoise_fun(&$r, &$g, &$b, $amount)
114
-	{				
115
-		$rand = mt_rand(0, $amount) - ($amount >> 1);
103
+    /**
104
+     * Adds mono noise by altering given R,G,B values using specififed amount
105
+     *
106
+     * @param int $r
107
+     * @param int $g
108
+     * @param int $b
109
+     * @param int $value		 
110
+     * @return void
111
+     */
112
+    public function monoNoise_fun(&$r, &$g, &$b, $amount)
113
+    {				
114
+        $rand = mt_rand(0, $amount) - ($amount >> 1);
116 115
 		
117
-		$r = static::byte($r + $rand);
118
-		$g = static::byte($g + $rand);
119
-		$b = static::byte($b + $rand);
120
-	}
116
+        $r = static::byte($r + $rand);
117
+        $g = static::byte($g + $rand);
118
+        $b = static::byte($b + $rand);
119
+    }
121 120
 	
122
-	/**
123
-	 * Adds salt&pepper noise by altering given R,G,B values using specififed amount
124
-	 *
125
-	 * @param int $r
126
-	 * @param int $g
127
-	 * @param int $b
128
-	 * @param int $value		 
129
-	 * @return void
130
-	 */
131
-	public function saltPepperNoise_fun(&$r, &$g, &$b, $amount)
132
-	{
133
-		if (mt_rand(0, 255 - $amount) != 0) {
134
-			return;
135
-		}
121
+    /**
122
+     * Adds salt&pepper noise by altering given R,G,B values using specififed amount
123
+     *
124
+     * @param int $r
125
+     * @param int $g
126
+     * @param int $b
127
+     * @param int $value		 
128
+     * @return void
129
+     */
130
+    public function saltPepperNoise_fun(&$r, &$g, &$b, $amount)
131
+    {
132
+        if (mt_rand(0, 255 - $amount) != 0) {
133
+            return;
134
+        }
136 135
 		
137
-		$rand = mt_rand(0, 1);
136
+        $rand = mt_rand(0, 1);
138 137
 		
139
-		switch ($rand) {
140
-			case 0:
141
-				$r = $g = $b = 0;
142
-				break;
143
-			case 1:
144
-				$r = $g = $b = 255;
145
-				break;
146
-		}
147
-	}
138
+        switch ($rand) {
139
+            case 0:
140
+                $r = $g = $b = 0;
141
+                break;
142
+            case 1:
143
+                $r = $g = $b = 255;
144
+                break;
145
+        }
146
+    }
148 147
 	
149
-	/**
150
-	 * Returns value within (0,255)
151
-	 *
152
-	 * @param int $b		 
153
-	 * @return int
154
-	 */		
155
-	public function byte($b)
156
-	{
157
-		if ($b > 255) {
158
-			return 255;
159
-		}
148
+    /**
149
+     * Returns value within (0,255)
150
+     *
151
+     * @param int $b		 
152
+     * @return int
153
+     */		
154
+    public function byte($b)
155
+    {
156
+        if ($b > 255) {
157
+            return 255;
158
+        }
160 159
 		
161
-		if ($b < 0) {
162
-			return 0;
163
-		}
160
+        if ($b < 0) {
161
+            return 0;
162
+        }
164 163
 		
165
-		return (int) $b;
166
-	}
164
+        return (int) $b;
165
+    }
167 166
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	public function filter($image, $function, $value)
68 68
 	{
69 69
 		for ($y = 0; $y < $image->getHeight(); $y++) {
70
-	    	for ($x = 0; $x< $image->getWidth(); $x++) {	     
70
+	    	for ($x = 0; $x < $image->getWidth(); $x++) {	     
71 71
 				$rgb = imagecolorat($image->getHandle(), $x, $y);				
72 72
 				
73 73
 				$a = ($rgb >> 24) & 0xFF;
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function colorNoise_fun(&$r, &$g, &$b, $amount)
98 98
 	{				
99
-		$r = static::byte($r + mt_rand(0, $amount) - ($amount >> 1) );
100
-		$g = static::byte($g + mt_rand(0, $amount) - ($amount >> 1) );
101
-		$b = static::byte($b + mt_rand(0, $amount) - ($amount >> 1) );
99
+		$r = static::byte($r + mt_rand(0, $amount) - ($amount >> 1));
100
+		$g = static::byte($g + mt_rand(0, $amount) - ($amount >> 1));
101
+		$b = static::byte($b + mt_rand(0, $amount) - ($amount >> 1));
102 102
 	}
103 103
 	
104 104
 	/**
@@ -162,6 +162,6 @@  discard block
 block discarded – undo
162 162
 			return 0;
163 163
 		}
164 164
 		
165
-		return (int) $b;
165
+		return (int)$b;
166 166
 	}
167 167
 }
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/Operation/Mirror.php 1 patch
Indentation   +24 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
32 31
  */
33 32
 class Mirror
34 33
 {
35
-	/**
36
-	 * Returns a mirrored 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 mirrored 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 ($x = 0; $x < $width; $x++) {
53
-			if (!imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height)) { 
54
-				throw new GDFunctionResultException("imagecopy() returned false");
55
-			}
56
-		}
51
+        for ($x = 0; $x < $width; $x++) {
52
+            if (!imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height)) { 
53
+                throw new GDFunctionResultException("imagecopy() returned false");
54
+            }
55
+        }
57 56
 		
58
-		return $new;
59
-	}
57
+        return $new;
58
+    }
60 59
 }
Please login to merge, or discard this patch.
libraries/vendor/smottt/wideimage/lib/WideImage/Operation/AsGrayscale.php 1 patch
Indentation   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,24 +31,24 @@  discard block
 block discarded – undo
32 31
  */
33 32
 class AsGrayscale
34 33
 {
35
-	/**
36
-	 * Returns a greyscale copy of an image
37
-	 *
38
-	 * @param \WideImage\Image $image
39
-	 * @return \WideImage\Image
40
-	 */
41
-	public function execute($image)
42
-	{
43
-		$new = $image->asTrueColor();
34
+    /**
35
+     * Returns a greyscale copy of an image
36
+     *
37
+     * @param \WideImage\Image $image
38
+     * @return \WideImage\Image
39
+     */
40
+    public function execute($image)
41
+    {
42
+        $new = $image->asTrueColor();
44 43
 		
45
-		if (!imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE)) {
46
-			throw new GDFunctionResultException("imagefilter() returned false");
47
-		}
44
+        if (!imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE)) {
45
+            throw new GDFunctionResultException("imagefilter() returned false");
46
+        }
48 47
 		
49
-		if (!$image->isTrueColor()) {
50
-			$new = $new->asPalette();
51
-		}
48
+        if (!$image->isTrueColor()) {
49
+            $new = $new->asPalette();
50
+        }
52 51
 		
53
-		return $new;
54
-	}
52
+        return $new;
53
+    }
55 54
 }
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/Operation/Merge.php 1 patch
Indentation   +45 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,50 +32,50 @@  discard block
 block discarded – undo
33 32
  */
34 33
 class Merge
35 34
 {
36
-	/**
37
-	 * Returns a merged image
38
-	 *
39
-	 * @param \WideImage\Image $base
40
-	 * @param \WideImage\Image $overlay
41
-	 * @param smart_coordinate $left
42
-	 * @param smart_coordinate $top
43
-	 * @param numeric $pct
44
-	 * @return \WideImage\Image
45
-	 */
46
-	public function execute($base, $overlay, $left, $top, $pct)
47
-	{
48
-		$x = Coordinate::fix($left, $base->getWidth(), $overlay->getWidth());
49
-		$y = Coordinate::fix($top, $base->getHeight(), $overlay->getHeight());
35
+    /**
36
+     * Returns a merged image
37
+     *
38
+     * @param \WideImage\Image $base
39
+     * @param \WideImage\Image $overlay
40
+     * @param smart_coordinate $left
41
+     * @param smart_coordinate $top
42
+     * @param numeric $pct
43
+     * @return \WideImage\Image
44
+     */
45
+    public function execute($base, $overlay, $left, $top, $pct)
46
+    {
47
+        $x = Coordinate::fix($left, $base->getWidth(), $overlay->getWidth());
48
+        $y = Coordinate::fix($top, $base->getHeight(), $overlay->getHeight());
50 49
 		
51
-		$result = $base->asTrueColor();
52
-		$result->alphaBlending(true);
53
-		$result->saveAlpha(true);
50
+        $result = $base->asTrueColor();
51
+        $result->alphaBlending(true);
52
+        $result->saveAlpha(true);
54 53
 		
55
-		if ($pct <= 0) {
56
-			return $result;
57
-		}
54
+        if ($pct <= 0) {
55
+            return $result;
56
+        }
58 57
 		
59
-		if ($pct < 100) {
60
-			if (!imagecopymerge(
61
-				$result->getHandle(), 
62
-				$overlay->getHandle(), 
63
-				$x, $y, 0, 0, 
64
-				$overlay->getWidth(), 
65
-				$overlay->getHeight(), 
66
-				$pct)) {
67
-					throw new GDFunctionResultException("imagecopymerge() returned false");
68
-			}
69
-		} else {
70
-			if (!imagecopy(
71
-				$result->getHandle(), 
72
-				$overlay->getHandle(), 
73
-				$x, $y, 0, 0, 
74
-				$overlay->getWidth(), 
75
-				$overlay->getHeight())) {
76
-					throw new GDFunctionResultException("imagecopy() returned false");
77
-			}
78
-		}
58
+        if ($pct < 100) {
59
+            if (!imagecopymerge(
60
+                $result->getHandle(), 
61
+                $overlay->getHandle(), 
62
+                $x, $y, 0, 0, 
63
+                $overlay->getWidth(), 
64
+                $overlay->getHeight(), 
65
+                $pct)) {
66
+                    throw new GDFunctionResultException("imagecopymerge() returned false");
67
+            }
68
+        } else {
69
+            if (!imagecopy(
70
+                $result->getHandle(), 
71
+                $overlay->getHandle(), 
72
+                $x, $y, 0, 0, 
73
+                $overlay->getWidth(), 
74
+                $overlay->getHeight())) {
75
+                    throw new GDFunctionResultException("imagecopy() returned false");
76
+            }
77
+        }
79 78
 		
80
-		return $result;
81
-	}
79
+        return $result;
80
+    }
82 81
 }
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/Operation/Resize.php 1 patch
Indentation   +123 added lines, -124 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/Operation/Crop.php 1 patch
Indentation   +51 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -35,62 +34,62 @@  discard block
 block discarded – undo
35 34
  */
36 35
 class Crop
37 36
 {
38
-	/**
39
-	 * Returns a cropped image
40
-	 *
41
-	 * @param \WideImage\Image $img
42
-	 * @param smart_coordinate $left
43
-	 * @param smart_coordinate $top
44
-	 * @param smart_coordinate $width
45
-	 * @param smart_coordinate $height
46
-	 * @return \WideImage\Image
47
-	 */
48
-	public function execute($img, $left, $top, $width, $height)
49
-	{
50
-		$width  = Coordinate::fix($width, $img->getWidth(), $width);
51
-		$height = Coordinate::fix($height, $img->getHeight(), $height);
52
-		$left   = Coordinate::fix($left, $img->getWidth(), $width);
53
-		$top    = Coordinate::fix($top, $img->getHeight(), $height);
37
+    /**
38
+     * Returns a cropped image
39
+     *
40
+     * @param \WideImage\Image $img
41
+     * @param smart_coordinate $left
42
+     * @param smart_coordinate $top
43
+     * @param smart_coordinate $width
44
+     * @param smart_coordinate $height
45
+     * @return \WideImage\Image
46
+     */
47
+    public function execute($img, $left, $top, $width, $height)
48
+    {
49
+        $width  = Coordinate::fix($width, $img->getWidth(), $width);
50
+        $height = Coordinate::fix($height, $img->getHeight(), $height);
51
+        $left   = Coordinate::fix($left, $img->getWidth(), $width);
52
+        $top    = Coordinate::fix($top, $img->getHeight(), $height);
54 53
 		
55
-		if ($left < 0) {
56
-			$width = $left + $width;
57
-			$left  = 0;
58
-		}
54
+        if ($left < 0) {
55
+            $width = $left + $width;
56
+            $left  = 0;
57
+        }
59 58
 		
60
-		if ($width > $img->getWidth() - $left) {
61
-			$width = $img->getWidth() - $left;
62
-		}
59
+        if ($width > $img->getWidth() - $left) {
60
+            $width = $img->getWidth() - $left;
61
+        }
63 62
 		
64
-		if ($top < 0) {
65
-			$height = $top + $height;
66
-			$top    = 0;
67
-		}
63
+        if ($top < 0) {
64
+            $height = $top + $height;
65
+            $top    = 0;
66
+        }
68 67
 		
69
-		if ($height > $img->getHeight() - $top) {
70
-			$height = $img->getHeight() - $top;
71
-		}
68
+        if ($height > $img->getHeight() - $top) {
69
+            $height = $img->getHeight() - $top;
70
+        }
72 71
 		
73
-		if ($width <= 0 || $height <= 0) {
74
-			throw new Exception("Can't crop outside of an image.");
75
-		}
72
+        if ($width <= 0 || $height <= 0) {
73
+            throw new Exception("Can't crop outside of an image.");
74
+        }
76 75
 		
77
-		$new = $img->doCreate($width, $height);
76
+        $new = $img->doCreate($width, $height);
78 77
 		
79
-		if ($img->isTransparent() || $img instanceof PaletteImage) {
80
-			$new->copyTransparencyFrom($img);
78
+        if ($img->isTransparent() || $img instanceof PaletteImage) {
79
+            $new->copyTransparencyFrom($img);
81 80
 			
82
-			if (!imagecopyresized($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) {
83
-				throw new GDFunctionResultException("imagecopyresized() returned false");
84
-			}
85
-		} else {
86
-			$new->alphaBlending(false);
87
-			$new->saveAlpha(true);
81
+            if (!imagecopyresized($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) {
82
+                throw new GDFunctionResultException("imagecopyresized() returned false");
83
+            }
84
+        } else {
85
+            $new->alphaBlending(false);
86
+            $new->saveAlpha(true);
88 87
 			
89
-			if (!imagecopyresampled($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) {
90
-				throw new GDFunctionResultException("imagecopyresampled() returned false");
91
-			}
92
-		}
88
+            if (!imagecopyresampled($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) {
89
+                throw new GDFunctionResultException("imagecopyresampled() returned false");
90
+            }
91
+        }
93 92
 		
94
-		return $new;
95
-	}
93
+        return $new;
94
+    }
96 95
 }
Please login to merge, or discard this patch.