Completed
Push — master ( 9528ad...369c90 )
by Michael
03:33
created
class/wideimage/Font/GDF.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,10 +34,11 @@
 block discarded – undo
34 34
 		
35 35
 		function __construct($face, $color)
36 36
 		{
37
-			if (is_int($face) && $face >= 1 && $face <= 5)
38
-				$this->font = $face;
39
-			else
40
-				$this->font = imageloadfont($face);
37
+			if (is_int($face) && $face >= 1 && $face <= 5) {
38
+							$this->font = $face;
39
+			} else {
40
+							$this->font = imageloadfont($face);
41
+			}
41 42
 			$this->color = $color;
42 43
 		}
43 44
 		
Please login to merge, or discard this patch.
class/wideimage/Font/PS.php 1 patch
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,16 +38,18 @@
 block discarded – undo
38 38
 			$this->handle = imagepsloadfont($file);
39 39
 			$this->size = $size;
40 40
 			$this->color = $color;
41
-			if ($bgcolor === null)
42
-				$this->bgcolor = $color;
43
-			else
44
-				$this->color = $color;
41
+			if ($bgcolor === null) {
42
+							$this->bgcolor = $color;
43
+			} else {
44
+							$this->color = $color;
45
+			}
45 46
 		}
46 47
 		
47 48
 		function writeText($image, $x, $y, $text, $angle = 0)
48 49
 		{
49
-			if ($image->isTrueColor())
50
-				$image->alphaBlending(true);
50
+			if ($image->isTrueColor()) {
51
+							$image->alphaBlending(true);
52
+			}
51 53
 			
52 54
 			imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4);
53 55
 		}
Please login to merge, or discard this patch.
class/wideimage/Font/TTF.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@
 block discarded – undo
42 42
 		
43 43
 		function writeText($image, $x, $y, $text, $angle = 0)
44 44
 		{
45
-			if ($image->isTrueColor())
46
-				$image->alphaBlending(true);
45
+			if ($image->isTrueColor()) {
46
+							$image->alphaBlending(true);
47
+			}
47 48
 			
48 49
 			imagettftext($image->getHandle(), $this->size, $angle, $x, $y, $this->color, $this->face, $text);
49 50
 		}
Please login to merge, or discard this patch.
class/wideimage/Coordinate.php 1 patch
Braces   +38 added lines, -28 removed lines patch added patch discarded remove patch
@@ -47,22 +47,25 @@  discard block
 block discarded – undo
47 47
 		{
48 48
 			$coord = trim($coord);
49 49
 			
50
-			if (strlen($coord) == 0)
51
-				return array('type' => 'abs', 'value' => '+0');
50
+			if (strlen($coord) == 0) {
51
+							return array('type' => 'abs', 'value' => '+0');
52
+			}
52 53
 			
53 54
 			$comp_regex = implode('|', self::$coord_regex);
54 55
 			
55 56
 			if (preg_match("/^([+-])?(\s+)?({$comp_regex})$/", $coord, $match))
56 57
 			{
57
-				if ($match[1] == '')
58
-					$match[1] = '+';
58
+				if ($match[1] == '') {
59
+									$match[1] = '+';
60
+				}
59 61
 				return array('type' => 'abs', 'value' => $match[1] . $match[3]);
60 62
 			}
61 63
 			
62 64
 			if (preg_match("/^([+-])?(\s+)?({$comp_regex})(\s+)?([+-])(\s+)?({$comp_regex})$/", $coord, $match))
63 65
 			{
64
-				if ($match[1] == '')
65
-					$match[1] = '+';
66
+				if ($match[1] == '') {
67
+									$match[1] = '+';
68
+				}
66 69
 				return array('type' => 'cal', 'pivot' => $match[1] . $match[3], 'value' => $match[5] . $match[7]);
67 70
 			}
68 71
 		}
@@ -81,10 +84,11 @@  discard block
 block discarded – undo
81 84
 			{
82 85
 				$sign = intval($matches[1] . "1");
83 86
 				$val = $matches[2];
84
-				if (substr($val, -1) === '%')
85
-					return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
86
-				else
87
-					return $sign * intval(round($val));
87
+				if (substr($val, -1) === '%') {
88
+									return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
89
+				} else {
90
+									return $sign * intval(round($val));
91
+				}
88 92
 			}
89 93
 		}
90 94
 		
@@ -99,14 +103,14 @@  discard block
 block discarded – undo
99 103
 		static function fix($dim, $value, $clip = false)
100 104
 		{
101 105
 			$coord = self::parse($value);
102
-			if ($coord === null)
103
-				throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
106
+			if ($coord === null) {
107
+							throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
108
+			}
104 109
 			
105 110
 			if ($coord['type'] === 'abs')
106 111
 			{
107 112
 				$result = self::evaluate($coord['value'], $dim);
108
-			}
109
-			elseif ($coord['type'] === 'cal')
113
+			} elseif ($coord['type'] === 'cal')
110 114
 			{
111 115
 				$p = self::evaluate($coord['pivot'], $dim);
112 116
 				$v = self::evaluate($coord['value'], $dim);
@@ -115,10 +119,11 @@  discard block
 block discarded – undo
115 119
 			
116 120
 			if ($clip)
117 121
 			{
118
-				if ($result < 0)
119
-					return 0;
120
-				elseif ($result >= $dim)
121
-					return $dim;
122
+				if ($result < 0) {
123
+									return 0;
124
+				} elseif ($result >= $dim) {
125
+									return $dim;
126
+				}
122 127
 			}
123 128
 			return $result;
124 129
 		}
@@ -133,20 +138,25 @@  discard block
 block discarded – undo
133 138
 		 */
134 139
 		static function fixForResize($img, $width, $height)
135 140
 		{
136
-			if ($width === null && $height === null)
137
-				return array($img->getWidth(), $img->getHeight());
141
+			if ($width === null && $height === null) {
142
+							return array($img->getWidth(), $img->getHeight());
143
+			}
138 144
 			
139
-			if ($width !== null)
140
-				$width = self::fix($img->getWidth(), $width);
145
+			if ($width !== null) {
146
+							$width = self::fix($img->getWidth(), $width);
147
+			}
141 148
 			
142
-			if ($height !== null)
143
-				$height = self::fix($img->getHeight(), $height);
149
+			if ($height !== null) {
150
+							$height = self::fix($img->getHeight(), $height);
151
+			}
144 152
 			
145
-			if ($width === null)
146
-				$width = floor($img->getWidth() * $height / $img->getHeight());
153
+			if ($width === null) {
154
+							$width = floor($img->getWidth() * $height / $img->getHeight());
155
+			}
147 156
 			
148
-			if ($height === null)
149
-				$height = floor($img->getHeight() * $width / $img->getWidth());
157
+			if ($height === null) {
158
+							$height = floor($img->getHeight() * $width / $img->getWidth());
159
+			}
150 160
 			
151 161
 			return array($width, $height);
152 162
 		}
Please login to merge, or discard this patch.
class/wideimage/Operation/AutoCrop.php 1 patch
Braces   +24 added lines, -17 removed lines patch added patch discarded remove patch
@@ -43,19 +43,22 @@  discard block
 block discarded – undo
43 43
 			$margin = intval($margin);
44 44
 			
45 45
 			$rgb_threshold = intval($rgb_threshold);
46
-			if ($rgb_threshold < 0)
47
-				$rgb_threshold = 0;
46
+			if ($rgb_threshold < 0) {
47
+							$rgb_threshold = 0;
48
+			}
48 49
 			
49 50
 			$pixel_cutoff = intval($pixel_cutoff);
50
-			if ($pixel_cutoff <= 1)
51
-				$pixel_cutoff = 1;
51
+			if ($pixel_cutoff <= 1) {
52
+							$pixel_cutoff = 1;
53
+			}
52 54
 			
53
-			if ($base_color === null)
54
-				$rgb_base = $img->getRGBAt(0, 0);
55
-			else
55
+			if ($base_color === null) {
56
+							$rgb_base = $img->getRGBAt(0, 0);
57
+			} else
56 58
 			{
57
-				if ($base_color < 0)
58
-					return $img->copy();
59
+				if ($base_color < 0) {
60
+									return $img->copy();
61
+				}
59 62
 				
60 63
 				$rgb_base = $img->getColorRGB($base_color);
61 64
 			}
@@ -145,17 +148,21 @@  discard block
 block discarded – undo
145 148
 					'bottom' => $cut_rect['bottom'] + $margin
146 149
 				);
147 150
 			
148
-			if ($cut_rect['left'] < 0)
149
-				$cut_rect['left'] = 0;
151
+			if ($cut_rect['left'] < 0) {
152
+							$cut_rect['left'] = 0;
153
+			}
150 154
 			
151
-			if ($cut_rect['top'] < 0)
152
-				$cut_rect['top'] = 0;
155
+			if ($cut_rect['top'] < 0) {
156
+							$cut_rect['top'] = 0;
157
+			}
153 158
 			
154
-			if ($cut_rect['right'] >= $img->getWidth())
155
-				$cut_rect['right'] = $img->getWidth() - 1;
159
+			if ($cut_rect['right'] >= $img->getWidth()) {
160
+							$cut_rect['right'] = $img->getWidth() - 1;
161
+			}
156 162
 			
157
-			if ($cut_rect['bottom'] >= $img->getHeight())
158
-				$cut_rect['bottom'] = $img->getHeight() - 1;
163
+			if ($cut_rect['bottom'] >= $img->getHeight()) {
164
+							$cut_rect['bottom'] = $img->getHeight() - 1;
165
+			}
159 166
 			
160 167
 			return $img->crop($cut_rect['left'], $cut_rect['top'], $cut_rect['right'] - $cut_rect['left'] + 1, $cut_rect['bottom'] - $cut_rect['top'] + 1);
161 168
 		}
Please login to merge, or discard this patch.
class/wideimage/Operation/CopyChannelsTrueColor.php 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,18 +46,24 @@
 block discarded – undo
46 46
 			$height = $img->getHeight();
47 47
 			$copy = WideImage_TrueColorImage::create($width, $height);
48 48
 			
49
-			if (count($channels) > 0)
50
-				for ($x = 0; $x < $width; $x++)
51
-					for ($y = 0; $y < $height; $y++)
49
+			if (count($channels) > 0) {
50
+							for ($x = 0;
51
+			}
52
+			$x < $width; $x++) {
53
+									for ($y = 0;
54
+				}
55
+				$y < $height; $y++)
52 56
 					{
53 57
 						$RGBA = $img->getRGBAt($x, $y);
54 58
 						$newRGBA = $blank;
55
-						foreach ($channels as $channel)
56
-							$newRGBA[$channel] = $RGBA[$channel];
59
+						foreach ($channels as $channel) {
60
+													$newRGBA[$channel] = $RGBA[$channel];
61
+						}
57 62
 						
58 63
 						$color = $copy->getExactColorAlpha($newRGBA);
59
-						if ($color == -1)
60
-							$color = $copy->allocateColorAlpha($newRGBA);
64
+						if ($color == -1) {
65
+													$color = $copy->allocateColorAlpha($newRGBA);
66
+						}
61 67
 						
62 68
 						$copy->setColorAt($x, $y, $color);
63 69
 					}
Please login to merge, or discard this patch.
class/wideimage/Operation/GetMask.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,21 +45,25 @@
 block discarded – undo
45 45
 			$mask->alphaBlending(false);
46 46
 			$mask->saveAlpha(false);
47 47
 			
48
-			for ($i = 0; $i <= 255; $i++)
49
-				$greyscale[$i] = ImageColorAllocate($mask->getHandle(), $i, $i, $i);
48
+			for ($i = 0; $i <= 255; $i++) {
49
+							$greyscale[$i] = ImageColorAllocate($mask->getHandle(), $i, $i, $i);
50
+			}
50 51
 			
51 52
 			imagefilledrectangle($mask->getHandle(), 0, 0, $width, $height, $greyscale[255]);
52 53
 			
53 54
 			$transparentColor = $image->getTransparentColor();
54 55
 			$alphaToGreyRatio = 255 / 127;
55
-			for ($x = 0; $x < $width; $x++)
56
-				for ($y = 0; $y < $height; $y++)
56
+			for ($x = 0; $x < $width; $x++) {
57
+							for ($y = 0;
58
+			}
59
+			$y < $height; $y++)
57 60
 				{
58 61
 					$color = $image->getColorAt($x, $y);
59
-					if ($color == $transparentColor)
60
-						$rgba['alpha'] = 127;
61
-					else
62
-						$rgba = $image->getColorRGB($color);
62
+					if ($color == $transparentColor) {
63
+											$rgba['alpha'] = 127;
64
+					} else {
65
+											$rgba = $image->getColorRGB($color);
66
+					}
63 67
 					imagesetpixel($mask->getHandle(), $x, $y, $greyscale[255 - round($rgba['alpha'] * $alphaToGreyRatio)]);
64 68
 				}
65 69
 			return $mask;
Please login to merge, or discard this patch.
class/wideimage/Operation/Unsharp.php 1 patch
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,11 +44,17 @@  discard block
 block discarded – undo
44 44
 		function execute($image, $amount, $radius, $threshold) {
45 45
 			
46 46
 			// Attempt to calibrate the parameters to Photoshop:
47
-			if ($amount > 500)    $amount = 500;
47
+			if ($amount > 500) {
48
+				$amount = 500;
49
+			}
48 50
 			$amount = $amount * 0.016;
49
-			if ($radius > 50)    $radius = 50;
51
+			if ($radius > 50) {
52
+				$radius = 50;
53
+			}
50 54
 			$radius = $radius * 2;
51
-			if ($threshold > 255)    $threshold = 255;
55
+			if ($threshold > 255) {
56
+				$threshold = 255;
57
+			}
52 58
 			
53 59
 			$radius = abs(round($radius));     // Only integers make sense.
54 60
 			if ($radius == 0) {
@@ -98,8 +104,7 @@  discard block
 block discarded – undo
98 104
 						}
99 105
 					}
100 106
 				}
101
-			}
102
-			else {
107
+			} else {
103 108
 				$w = $image->getWidth();
104 109
 				$h = $image->getHeight();
105 110
 				for ($x = 0; $x < $w; $x++)    { // each row
@@ -115,14 +120,11 @@  discard block
 block discarded – undo
115 120
 						$bBlur = $rgbBlur["blue"];
116 121
 						
117 122
 						$rNew = ($amount * ($rOrig - $rBlur)) + $rOrig;
118
-							if($rNew>255){$rNew=255;}
119
-							elseif($rNew<0){$rNew=0;}
123
+							if($rNew>255){$rNew=255;} elseif($rNew<0){$rNew=0;}
120 124
 						$gNew = ($amount * ($gOrig - $gBlur)) + $gOrig;
121
-							if($gNew>255){$gNew=255;}
122
-							elseif($gNew<0){$gNew=0;}
125
+							if($gNew>255){$gNew=255;} elseif($gNew<0){$gNew=0;}
123 126
 						$bNew = ($amount * ($bOrig - $bBlur)) + $bOrig;
124
-							if($bNew>255){$bNew=255;}
125
-							elseif($bNew<0){$bNew=0;}
127
+							if($bNew>255){$bNew=255;} elseif($bNew<0){$bNew=0;}
126 128
 						$rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0);
127 129
 						
128 130
 						$image->setRGBAt($x, $y, $rgbNew);
Please login to merge, or discard this patch.
class/wideimage/Operation/AsGrayscale.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 			$palette = $image instanceof WideImage_PaletteImage;
41 41
 			$transparent = $image->isTransparent();
42 42
 			
43
-			if ($palette && $transparent)
44
-				$tci = $image->getTransparentColor();
43
+			if ($palette && $transparent) {
44
+							$tci = $image->getTransparentColor();
45
+			}
45 46
 			
46 47
 			$new = $image->asTrueColor();
47 48
 			imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE);
@@ -49,8 +50,9 @@  discard block
 block discarded – undo
49 50
 			if ($palette)
50 51
 			{
51 52
 				$new = $new->asPalette();
52
-				if ($transparent)
53
-					$new->setTransparentColor($tci);
53
+				if ($transparent) {
54
+									$new->setTransparentColor($tci);
55
+				}
54 56
 			}
55 57
 			
56 58
 			return $new;
Please login to merge, or discard this patch.