Test Failed
Push — master ( 398493...d4ef72 )
by Michael
11:04
created
htdocs/class/libraries/vendor/xoops/xmf/src/Highlighter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
         $encoding = static::ENCODING;
70 70
         return preg_replace_callback(
71 71
             '#((?:(?!<[/a-z]).)*)([^>]*>|$)#si',
72
-            function ($capture) use ($needle, $pre, $post, $encoding) {
72
+            function($capture) use ($needle, $pre, $post, $encoding) {
73 73
                 $haystack = $capture[1];
74 74
                 if (function_exists('mb_substr')) {
75 75
                     $p1 = mb_stripos($haystack, $needle, 0, $encoding);
76 76
                     $l1 = mb_strlen($needle, $encoding);
77 77
                     $ret = '';
78 78
                     while ($p1 !== false) {
79
-                        $ret .= mb_substr($haystack, 0, $p1, $encoding) . $pre
80
-                            . mb_substr($haystack, $p1, $l1, $encoding) . $post;
79
+                        $ret .= mb_substr($haystack, 0, $p1, $encoding).$pre
80
+                            . mb_substr($haystack, $p1, $l1, $encoding).$post;
81 81
                         $haystack = mb_substr($haystack, $p1 + $l1, mb_strlen($haystack), $encoding);
82 82
                         $p1 = mb_stripos($haystack, $needle, 0, $encoding);
83 83
                     }
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
                     $l1 = strlen($needle);
87 87
                     $ret = '';
88 88
                     while ($p1 !== false) {
89
-                        $ret .= substr($haystack, 0, $p1) . $pre . substr($haystack, $p1, $l1) . $post;
89
+                        $ret .= substr($haystack, 0, $p1).$pre.substr($haystack, $p1, $l1).$post;
90 90
                         $haystack = substr($haystack, $p1 + $l1);
91 91
                         $p1 = stripos($haystack, $needle);
92 92
                     }
93 93
                 }
94
-                $ret .= $haystack . $capture[2];
94
+                $ret .= $haystack.$capture[2];
95 95
 
96 96
                 return $ret;
97 97
             },
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/firebase/php-jwt/src/JWT.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         // token can actually be used. If it's not yet that time, abort.
117 117
         if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
118 118
             throw new BeforeValidException(
119
-                'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
119
+                'Cannot handle token prior to '.date(DateTime::ISO8601, $payload->nbf)
120 120
             );
121 121
         }
122 122
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         // correctly used the nbf claim).
126 126
         if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
127 127
             throw new BeforeValidException(
128
-                'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
128
+                'Cannot handle token prior to '.date(DateTime::ISO8601, $payload->iat)
129 129
             );
130 130
         }
131 131
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         if ($keyId !== null) {
160 160
             $header['kid'] = $keyId;
161 161
         }
162
-        if ( isset($head) && is_array($head) ) {
162
+        if (isset($head) && is_array($head)) {
163 163
             $header = array_merge($head, $header);
164 164
         }
165 165
         $segments = array();
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             throw new DomainException('Algorithm not supported');
192 192
         }
193 193
         list($function, $algorithm) = static::$supported_algs[$alg];
194
-        switch($function) {
194
+        switch ($function) {
195 195
             case 'hash_hmac':
196 196
                 return hash_hmac($algorithm, $msg, $key, true);
197 197
             case 'openssl':
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         }
226 226
 
227 227
         list($function, $algorithm) = static::$supported_algs[$alg];
228
-        switch($function) {
228
+        switch ($function) {
229 229
             case 'openssl':
230 230
                 $success = openssl_verify($msg, $signature, $key, $algorithm);
231 231
                 if ($success === 1) {
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                 }
236 236
                 // returns 1 on success, 0 on failure, -1 on error.
237 237
                 throw new DomainException(
238
-                    'OpenSSL error: ' . openssl_error_string()
238
+                    'OpenSSL error: '.openssl_error_string()
239 239
                 );
240 240
             case 'hash_hmac':
241 241
             default:
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
              * manually detect large ints in the JSON string and quote them (thus converting
278 278
              *them to strings) before decoding, hence the preg_replace() call.
279 279
              */
280
-            $max_int_length = strlen((string) PHP_INT_MAX) - 1;
280
+            $max_int_length = strlen((string)PHP_INT_MAX) - 1;
281 281
             $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
282 282
             $obj = json_decode($json_without_bigints);
283 283
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         throw new DomainException(
359 359
             isset($messages[$errno])
360 360
             ? $messages[$errno]
361
-            : 'Unknown JSON error: ' . $errno
361
+            : 'Unknown JSON error: '.$errno
362 362
         );
363 363
     }
364 364
 
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/autoload.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 block discarded – undo
2 2
 
3 3
 // autoload.php @generated by Composer
4 4
 
5
-require_once __DIR__ . '/composer/autoload_real.php';
5
+require_once __DIR__.'/composer/autoload_real.php';
6 6
 
7 7
 return ComposerAutoloaderInitfb0e5c3e4af98ed910184391855ba473::getLoader();
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/PaletteImage.php 1 patch
Indentation   +101 added lines, -102 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 WideImage
22
-  **/
20
+     * @package WideImage
21
+     **/
23 22
 
24 23
 namespace WideImage;
25 24
 
@@ -31,120 +30,120 @@  discard block
 block discarded – undo
31 30
  */
32 31
 class PaletteImage extends Image
33 32
 {
34
-	/**
35
-	 * Create a palette image
36
-	 *
37
-	 * @param int $width
38
-	 * @param int $height
39
-	 * @return \WideImage\PaletteImage
40
-	 */
41
-	public static function create($width, $height)
42
-	{
43
-		if ($width * $height <= 0 || $width < 0) {
44
-			throw new InvalidImageDimensionException("Can't create an image with dimensions [$width, $height].");
45
-		}
33
+    /**
34
+     * Create a palette image
35
+     *
36
+     * @param int $width
37
+     * @param int $height
38
+     * @return \WideImage\PaletteImage
39
+     */
40
+    public static function create($width, $height)
41
+    {
42
+        if ($width * $height <= 0 || $width < 0) {
43
+            throw new InvalidImageDimensionException("Can't create an image with dimensions [$width, $height].");
44
+        }
46 45
 		
47
-		return new PaletteImage(imagecreate($width, $height));
48
-	}
46
+        return new PaletteImage(imagecreate($width, $height));
47
+    }
49 48
 	
50
-	public function doCreate($width, $height)
51
-	{
52
-		return static::create($width, $height);
53
-	}
49
+    public function doCreate($width, $height)
50
+    {
51
+        return static::create($width, $height);
52
+    }
54 53
 	
55
-	/**
56
-	 * (non-PHPdoc)
57
-	 * @see \WideImage\Image#isTrueColor()
58
-	 */
59
-	public function isTrueColor()
60
-	{
61
-		return false;
62
-	}
54
+    /**
55
+     * (non-PHPdoc)
56
+     * @see \WideImage\Image#isTrueColor()
57
+     */
58
+    public function isTrueColor()
59
+    {
60
+        return false;
61
+    }
63 62
 	
64
-	/**
65
-	 * (non-PHPdoc)
66
-	 * @see \WideImage\Image#asPalette($nColors, $dither, $matchPalette)
67
-	 */
68
-	public function asPalette($nColors = 255, $dither = null, $matchPalette = true)
69
-	{
70
-		return $this->copy();
71
-	}
63
+    /**
64
+     * (non-PHPdoc)
65
+     * @see \WideImage\Image#asPalette($nColors, $dither, $matchPalette)
66
+     */
67
+    public function asPalette($nColors = 255, $dither = null, $matchPalette = true)
68
+    {
69
+        return $this->copy();
70
+    }
72 71
 	
73
-	/**
74
-	 * Returns a copy of the image
75
-	 * 
76
-	 * @param $trueColor True if the new image should be truecolor
77
-	 * @return \WideImage\Image
78
-	 */
79
-	protected function copyAsNew($trueColor = false)
80
-	{
81
-		$width = $this->getWidth();
82
-		$height = $this->getHeight();
72
+    /**
73
+     * Returns a copy of the image
74
+     * 
75
+     * @param $trueColor True if the new image should be truecolor
76
+     * @return \WideImage\Image
77
+     */
78
+    protected function copyAsNew($trueColor = false)
79
+    {
80
+        $width = $this->getWidth();
81
+        $height = $this->getHeight();
83 82
 		
84
-		if ($trueColor) {
85
-			$new = TrueColorImage::create($width, $height);
86
-		} else {
87
-			$new = PaletteImage::create($width, $height);
88
-		}
83
+        if ($trueColor) {
84
+            $new = TrueColorImage::create($width, $height);
85
+        } else {
86
+            $new = PaletteImage::create($width, $height);
87
+        }
89 88
 		
90
-		// copy transparency of source to target
91
-		if ($this->isTransparent()) {
92
-			$rgb = $this->getTransparentColorRGB();
89
+        // copy transparency of source to target
90
+        if ($this->isTransparent()) {
91
+            $rgb = $this->getTransparentColorRGB();
93 92
 			
94
-			if (is_array($rgb)) {
95
-				$tci = $new->allocateColor($rgb['red'], $rgb['green'], $rgb['blue']);
96
-				$new->fill(0, 0, $tci);
97
-				$new->setTransparentColor($tci);
98
-			}
99
-		}
93
+            if (is_array($rgb)) {
94
+                $tci = $new->allocateColor($rgb['red'], $rgb['green'], $rgb['blue']);
95
+                $new->fill(0, 0, $tci);
96
+                $new->setTransparentColor($tci);
97
+            }
98
+        }
100 99
 		
101
-		imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height);
100
+        imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height);
102 101
 		
103
-		return $new;
104
-	}
102
+        return $new;
103
+    }
105 104
 	
106
-	/**
107
-	 * (non-PHPdoc)
108
-	 * @see \WideImage\Image#asTrueColor()
109
-	 */
110
-	public function asTrueColor()
111
-	{
112
-		$width  = $this->getWidth();
113
-		$height = $this->getHeight();
114
-		$new    = WideImage::createTrueColorImage($width, $height);
105
+    /**
106
+     * (non-PHPdoc)
107
+     * @see \WideImage\Image#asTrueColor()
108
+     */
109
+    public function asTrueColor()
110
+    {
111
+        $width  = $this->getWidth();
112
+        $height = $this->getHeight();
113
+        $new    = WideImage::createTrueColorImage($width, $height);
115 114
 		
116
-		if ($this->isTransparent()) {
117
-			$new->copyTransparencyFrom($this);
118
-		}
115
+        if ($this->isTransparent()) {
116
+            $new->copyTransparencyFrom($this);
117
+        }
119 118
 		
120
-		if (!imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height)) {
121
-			throw new GDFunctionResultException("imagecopy() returned false");
122
-		}
119
+        if (!imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height)) {
120
+            throw new GDFunctionResultException("imagecopy() returned false");
121
+        }
123 122
 		
124
-		return $new;
125
-	}
123
+        return $new;
124
+    }
126 125
 	
127
-	/**
128
-	 * (non-PHPdoc)
129
-	 * @see \WideImage\Image#getChannels()
130
-	 */
131
-	public function getChannels()
132
-	{
133
-		$args = func_get_args();
126
+    /**
127
+     * (non-PHPdoc)
128
+     * @see \WideImage\Image#getChannels()
129
+     */
130
+    public function getChannels()
131
+    {
132
+        $args = func_get_args();
134 133
 		
135
-		if (count($args) == 1 && is_array($args[0])) {
136
-			$args = $args[0];
137
-		}
134
+        if (count($args) == 1 && is_array($args[0])) {
135
+            $args = $args[0];
136
+        }
138 137
 		
139
-		return OperationFactory::get('CopyChannelsPalette')->execute($this, $args);
140
-	}
138
+        return OperationFactory::get('CopyChannelsPalette')->execute($this, $args);
139
+    }
141 140
 	
142
-	/**
143
-	 * (non-PHPdoc)
144
-	 * @see \WideImage\Image#copyNoAlpha()
145
-	 */
146
-	public function copyNoAlpha()
147
-	{
148
-		return WideImage::loadFromString($this->asString('png'));
149
-	}
141
+    /**
142
+     * (non-PHPdoc)
143
+     * @see \WideImage\Image#copyNoAlpha()
144
+     */
145
+    public function copyNoAlpha()
146
+    {
147
+        return WideImage::loadFromString($this->asString('png'));
148
+    }
150 149
 }
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/Image.php 2 patches
Indentation   +928 added lines, -929 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 WideImage
22
-  **/
20
+     * @package WideImage
21
+     **/
23 22
 
24 23
 namespace WideImage;
25 24
 
@@ -33,947 +32,947 @@  discard block
 block discarded – undo
33 32
  */
34 33
 abstract class Image
35 34
 {
36
-	/**
37
-	 * Holds the image resource
38
-	 * @var resource
39
-	 */
40
-	protected $handle = null;
41
-	
42
-	/**
43
-	 * Flag that determines if WideImage should call imagedestroy() upon object destruction
44
-	 * @var bool
45
-	 */
46
-	protected $handleReleased = false;
47
-	
48
-	/**
49
-	 * Canvas object
50
-	 * @var \WideImage\Canvas
51
-	 */
52
-	protected $canvas = null;
53
-	
54
-	/**
55
-	 * @var string
56
-	 */
57
-	protected $sdata = null;
58
-	
59
-	/**
60
-	 * The base class constructor
61
-	 *
62
-	 * @param resource $handle Image handle (GD2 resource)
63
-	 */
64
-	public function __construct($handle)
65
-	{
66
-		WideImage::assertValidImageHandle($handle);
67
-		$this->handle = $handle;
68
-	}
69
-	
70
-	/**
71
-	 * Cleanup
72
-	 * 
73
-	 * Destroys the handle via \WideImage\Image::destroy() when called by the GC.
74
-	 */
75
-	public function __destruct()
76
-	{
77
-		$this->destroy();
78
-	}
79
-	
80
-	/**
81
-	 * This method destroy the image handle, and releases the image resource.
82
-	 * 
83
-	 * After this is called, the object doesn't hold a valid image any more.
84
-	 * No operation should be called after that.
85
-	 */
86
-	public function destroy()
87
-	{
88
-		if ($this->isValid() && !$this->handleReleased) {
89
-			imagedestroy($this->handle);
90
-		}
35
+    /**
36
+     * Holds the image resource
37
+     * @var resource
38
+     */
39
+    protected $handle = null;
40
+	
41
+    /**
42
+     * Flag that determines if WideImage should call imagedestroy() upon object destruction
43
+     * @var bool
44
+     */
45
+    protected $handleReleased = false;
46
+	
47
+    /**
48
+     * Canvas object
49
+     * @var \WideImage\Canvas
50
+     */
51
+    protected $canvas = null;
52
+	
53
+    /**
54
+     * @var string
55
+     */
56
+    protected $sdata = null;
57
+	
58
+    /**
59
+     * The base class constructor
60
+     *
61
+     * @param resource $handle Image handle (GD2 resource)
62
+     */
63
+    public function __construct($handle)
64
+    {
65
+        WideImage::assertValidImageHandle($handle);
66
+        $this->handle = $handle;
67
+    }
68
+	
69
+    /**
70
+     * Cleanup
71
+     * 
72
+     * Destroys the handle via \WideImage\Image::destroy() when called by the GC.
73
+     */
74
+    public function __destruct()
75
+    {
76
+        $this->destroy();
77
+    }
78
+	
79
+    /**
80
+     * This method destroy the image handle, and releases the image resource.
81
+     * 
82
+     * After this is called, the object doesn't hold a valid image any more.
83
+     * No operation should be called after that.
84
+     */
85
+    public function destroy()
86
+    {
87
+        if ($this->isValid() && !$this->handleReleased) {
88
+            imagedestroy($this->handle);
89
+        }
91 90
 		
92
-		$this->handle = null;
93
-	}
94
-	
95
-	/**
96
-	 * Returns the GD image resource
97
-	 * 
98
-	 * @return resource GD image resource
99
-	 */
100
-	public function getHandle()
101
-	{
102
-		return $this->handle;
103
-	}
104
-	
105
-	/**
106
-	 * @return bool True, if the image object holds a valid GD image, false otherwise
107
-	 */
108
-	public function isValid()
109
-	{
110
-		return WideImage::isValidImageHandle($this->handle);
111
-	}
112
-	
113
-	/**
114
-	 * Releases the handle
115
-	 */
116
-	public function releaseHandle()
117
-	{
118
-		$this->handleReleased = true;
119
-	}
120
-	
121
-	/**
122
-	 * Saves an image to a file
123
-	 * 
124
-	 * The file type is recognized from the $uri. If you save to a GIF8, truecolor images
125
-	 * are automatically converted to palette.
126
-	 * 
127
-	 * This method supports additional parameters: quality (for jpeg images) and 
128
-	 * compression quality and filters (for png images). See http://www.php.net/imagejpeg and
129
-	 * http://www.php.net/imagepng for details.
130
-	 * 
131
-	 * Examples:
132
-	 * <code>
133
-	 * // save to a GIF
134
-	 * $image->saveToFile('image.gif');
135
-	 * 
136
-	 * // save to a PNG with compression=7 and no filters
137
-	 * $image->saveToFile('image.png', 7, PNG_NO_FILTER);
138
-	 * 
139
-	 * // save to a JPEG with quality=80
140
-	 * $image->saveToFile('image.jpg', 80);
141
-	 * 
142
-	 * // save to a JPEG with default quality=100
143
-	 * $image->saveToFile('image.jpg');
144
-	 * </code>
145
-	 * 
146
-	 * @param string $uri File location
147
-	 */
148
-	public function saveToFile($uri)
149
-	{
150
-		$mapper = MapperFactory::selectMapper($uri, null);
151
-		$args = func_get_args();
152
-		array_unshift($args, $this->getHandle());
153
-		$res = call_user_func_array(array($mapper, 'save'), $args);
91
+        $this->handle = null;
92
+    }
93
+	
94
+    /**
95
+     * Returns the GD image resource
96
+     * 
97
+     * @return resource GD image resource
98
+     */
99
+    public function getHandle()
100
+    {
101
+        return $this->handle;
102
+    }
103
+	
104
+    /**
105
+     * @return bool True, if the image object holds a valid GD image, false otherwise
106
+     */
107
+    public function isValid()
108
+    {
109
+        return WideImage::isValidImageHandle($this->handle);
110
+    }
111
+	
112
+    /**
113
+     * Releases the handle
114
+     */
115
+    public function releaseHandle()
116
+    {
117
+        $this->handleReleased = true;
118
+    }
119
+	
120
+    /**
121
+     * Saves an image to a file
122
+     * 
123
+     * The file type is recognized from the $uri. If you save to a GIF8, truecolor images
124
+     * are automatically converted to palette.
125
+     * 
126
+     * This method supports additional parameters: quality (for jpeg images) and 
127
+     * compression quality and filters (for png images). See http://www.php.net/imagejpeg and
128
+     * http://www.php.net/imagepng for details.
129
+     * 
130
+     * Examples:
131
+     * <code>
132
+     * // save to a GIF
133
+     * $image->saveToFile('image.gif');
134
+     * 
135
+     * // save to a PNG with compression=7 and no filters
136
+     * $image->saveToFile('image.png', 7, PNG_NO_FILTER);
137
+     * 
138
+     * // save to a JPEG with quality=80
139
+     * $image->saveToFile('image.jpg', 80);
140
+     * 
141
+     * // save to a JPEG with default quality=100
142
+     * $image->saveToFile('image.jpg');
143
+     * </code>
144
+     * 
145
+     * @param string $uri File location
146
+     */
147
+    public function saveToFile($uri)
148
+    {
149
+        $mapper = MapperFactory::selectMapper($uri, null);
150
+        $args = func_get_args();
151
+        array_unshift($args, $this->getHandle());
152
+        $res = call_user_func_array(array($mapper, 'save'), $args);
154 153
 		
155
-		if (!$res) {
156
-			throw new UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while saving to $uri");
157
-		}
158
-	}
159
-	
160
-	/**
161
-	 * Returns binary string with image data in format specified by $format
162
-	 * 
163
-	 * Additional parameters may be passed to the function. See \WideImage\Image::saveToFile() for more details.
164
-	 * 
165
-	 * @param string $format The format of the image
166
-	 * @return string The binary image data in specified format
167
-	 */
168
-	public function asString($format)
169
-	{
170
-		ob_start();
171
-		$args = func_get_args();
172
-		$args[0] = null;
173
-		array_unshift($args, $this->getHandle());
154
+        if (!$res) {
155
+            throw new UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while saving to $uri");
156
+        }
157
+    }
158
+	
159
+    /**
160
+     * Returns binary string with image data in format specified by $format
161
+     * 
162
+     * Additional parameters may be passed to the function. See \WideImage\Image::saveToFile() for more details.
163
+     * 
164
+     * @param string $format The format of the image
165
+     * @return string The binary image data in specified format
166
+     */
167
+    public function asString($format)
168
+    {
169
+        ob_start();
170
+        $args = func_get_args();
171
+        $args[0] = null;
172
+        array_unshift($args, $this->getHandle());
174 173
 		
175
-		$mapper = MapperFactory::selectMapper(null, $format);
176
-		$res    = call_user_func_array(array($mapper, 'save'), $args);
174
+        $mapper = MapperFactory::selectMapper(null, $format);
175
+        $res    = call_user_func_array(array($mapper, 'save'), $args);
177 176
 		
178
-		if (!$res) {
179
-			throw new UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while writing the image data");
180
-		}
177
+        if (!$res) {
178
+            throw new UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while writing the image data");
179
+        }
181 180
 		
182
-		return ob_get_clean();
183
-	}
184
-	
185
-	/**
186
-	 * Output a header to browser.
187
-	 * 
188
-	 * @param $name Name of the header
189
-	 * @param $data Data
190
-	 */
191
-	protected function writeHeader($name, $data)
192
-	{
193
-		header($name . ": " . $data);
194
-	}
195
-	
196
-	/**
197
-	 * Outputs the image to browser
198
-	 * 
199
-	 * Sets headers Content-length and Content-type, and echoes the image in the specified format.
200
-	 * All other headers (such as Content-disposition) must be added manually. 
201
-	 * 
202
-	 * Example:
203
-	 * <code>
204
-	 * WideImage::load('image1.png')->resize(100, 100)->output('gif');
205
-	 * </code>
206
-	 * 
207
-	 * @param string $format Image format
208
-	 */
209
-	public function output($format)
210
-	{
211
-		$args = func_get_args();
212
-		$data = call_user_func_array(array($this, 'asString'), $args);
181
+        return ob_get_clean();
182
+    }
183
+	
184
+    /**
185
+     * Output a header to browser.
186
+     * 
187
+     * @param $name Name of the header
188
+     * @param $data Data
189
+     */
190
+    protected function writeHeader($name, $data)
191
+    {
192
+        header($name . ": " . $data);
193
+    }
194
+	
195
+    /**
196
+     * Outputs the image to browser
197
+     * 
198
+     * Sets headers Content-length and Content-type, and echoes the image in the specified format.
199
+     * All other headers (such as Content-disposition) must be added manually. 
200
+     * 
201
+     * Example:
202
+     * <code>
203
+     * WideImage::load('image1.png')->resize(100, 100)->output('gif');
204
+     * </code>
205
+     * 
206
+     * @param string $format Image format
207
+     */
208
+    public function output($format)
209
+    {
210
+        $args = func_get_args();
211
+        $data = call_user_func_array(array($this, 'asString'), $args);
213 212
 		
214
-		$this->writeHeader('Content-length', strlen($data));
215
-		$this->writeHeader('Content-type', MapperFactory::mimeType($format));
216
-		echo $data;
217
-	}
218
-	
219
-	/**
220
-	 * @return int Image width
221
-	 */
222
-	public function getWidth()
223
-	{
224
-		return imagesx($this->handle);
225
-	}
226
-	
227
-	/**
228
-	 * @return int Image height
229
-	 */
230
-	public function getHeight()
231
-	{
232
-		return imagesy($this->handle);
233
-	}
234
-	
235
-	/**
236
-	 * Allocate a color by RGB values.
237
-	 * 
238
-	 * @param mixed $R Red-component value or an RGB array (with red, green, blue keys)
239
-	 * @param int $G If $R is int, this is the green component
240
-	 * @param int $B If $R is int, this is the blue component
241
-	 * @return int Image color index
242
-	 */
243
-	public function allocateColor($R, $G = null, $B = null)
244
-	{
245
-		if (is_array($R)) {
246
-			return imageColorAllocate($this->handle, $R['red'], $R['green'], $R['blue']);
247
-		}
213
+        $this->writeHeader('Content-length', strlen($data));
214
+        $this->writeHeader('Content-type', MapperFactory::mimeType($format));
215
+        echo $data;
216
+    }
217
+	
218
+    /**
219
+     * @return int Image width
220
+     */
221
+    public function getWidth()
222
+    {
223
+        return imagesx($this->handle);
224
+    }
225
+	
226
+    /**
227
+     * @return int Image height
228
+     */
229
+    public function getHeight()
230
+    {
231
+        return imagesy($this->handle);
232
+    }
233
+	
234
+    /**
235
+     * Allocate a color by RGB values.
236
+     * 
237
+     * @param mixed $R Red-component value or an RGB array (with red, green, blue keys)
238
+     * @param int $G If $R is int, this is the green component
239
+     * @param int $B If $R is int, this is the blue component
240
+     * @return int Image color index
241
+     */
242
+    public function allocateColor($R, $G = null, $B = null)
243
+    {
244
+        if (is_array($R)) {
245
+            return imageColorAllocate($this->handle, $R['red'], $R['green'], $R['blue']);
246
+        }
248 247
 		
249
-		return imageColorAllocate($this->handle, $R, $G, $B);
250
-	}
251
-	
252
-	/**
253
-	 * @return bool True if the image is transparent, false otherwise
254
-	 */
255
-	public function isTransparent()
256
-	{
257
-		return $this->getTransparentColor() >= 0;
258
-	}
259
-	
260
-	/**
261
-	 * @return int Transparent color index
262
-	 */
263
-	public function getTransparentColor()
264
-	{
265
-		return imagecolortransparent($this->handle);
266
-	}
267
-	
268
-	/**
269
-	 * Sets the current transparent color index. Only makes sense for palette images (8-bit).
270
-	 * 
271
-	 * @param int $color Transparent color index
272
-	 */
273
-	public function setTransparentColor($color)
274
-	{
275
-		return imagecolortransparent($this->handle, $color);
276
-	}
277
-	
278
-	/**
279
-	 * Returns a RGB array of the transparent color or null if none.
280
-	 * 
281
-	 * @return mixed Transparent color RGBA array
282
-	 */
283
-	public function getTransparentColorRGB()
284
-	{
285
-		$total = imagecolorstotal($this->handle);
286
-		$tc    = $this->getTransparentColor();
248
+        return imageColorAllocate($this->handle, $R, $G, $B);
249
+    }
250
+	
251
+    /**
252
+     * @return bool True if the image is transparent, false otherwise
253
+     */
254
+    public function isTransparent()
255
+    {
256
+        return $this->getTransparentColor() >= 0;
257
+    }
258
+	
259
+    /**
260
+     * @return int Transparent color index
261
+     */
262
+    public function getTransparentColor()
263
+    {
264
+        return imagecolortransparent($this->handle);
265
+    }
266
+	
267
+    /**
268
+     * Sets the current transparent color index. Only makes sense for palette images (8-bit).
269
+     * 
270
+     * @param int $color Transparent color index
271
+     */
272
+    public function setTransparentColor($color)
273
+    {
274
+        return imagecolortransparent($this->handle, $color);
275
+    }
276
+	
277
+    /**
278
+     * Returns a RGB array of the transparent color or null if none.
279
+     * 
280
+     * @return mixed Transparent color RGBA array
281
+     */
282
+    public function getTransparentColorRGB()
283
+    {
284
+        $total = imagecolorstotal($this->handle);
285
+        $tc    = $this->getTransparentColor();
287 286
 		
288
-		if ($tc >= $total && $total > 0) {
289
-			return null;
290
-		}
287
+        if ($tc >= $total && $total > 0) {
288
+            return null;
289
+        }
291 290
 		
292
-		return $this->getColorRGB($tc);
293
-	}
294
-	
295
-	/**
296
-	 * Returns a RGBA array for pixel at $x, $y
297
-	 * 
298
-	 * @param int $x
299
-	 * @param int $y
300
-	 * @return array RGB array 
301
-	 */
302
-	public function getRGBAt($x, $y)
303
-	{
304
-		return $this->getColorRGB($this->getColorAt($x, $y));
305
-	}
306
-	
307
-	/**
308
-	 * Writes a pixel at the designated coordinates
309
-	 * 
310
-	 * Takes an associative array of colours and uses getExactColor() to
311
-	 * retrieve the exact index color to write to the image with.
312
-	 *
313
-	 * @param int $x
314
-	 * @param int $y
315
-	 * @param array $color
316
-	 */
317
-	public function setRGBAt($x, $y, $color)
318
-	{
319
-		$this->setColorAt($x, $y, $this->getExactColor($color));
320
-	}
321
-	
322
-	/**
323
-	 * Returns a color's RGB
324
-	 * 
325
-	 * @param int $colorIndex Color index
326
-	 * @return mixed RGBA array for a color with index $colorIndex
327
-	 */
328
-	public function getColorRGB($colorIndex)
329
-	{
330
-		return imageColorsForIndex($this->handle, $colorIndex);
331
-	}
332
-	
333
-	/**
334
-	 * Returns an index of the color at $x, $y
335
-	 * 
336
-	 * @param int $x
337
-	 * @param int $y
338
-	 * @return int Color index for a pixel at $x, $y
339
-	 */
340
-	public function getColorAt($x, $y)
341
-	{
342
-		return imagecolorat($this->handle, $x, $y);
343
-	}
344
-	
345
-	/**
346
-	 * Set the color index $color to a pixel at $x, $y
347
-	 * 
348
-	 * @param int $x
349
-	 * @param int $y
350
-	 * @param int $color Color index
351
-	 */
352
-	public function setColorAt($x, $y, $color)
353
-	{
354
-		return imagesetpixel($this->handle, $x, $y, $color);
355
-	}
356
-	
357
-	/**
358
-	 * Returns closest color index that matches the given RGB value. Uses
359
-	 * PHP's imagecolorclosest()
360
-	 * 
361
-	 * @param mixed $R Red or RGBA array
362
-	 * @param int $G Green component (or null if $R is an RGB array)
363
-	 * @param int $B Blue component (or null if $R is an RGB array)
364
-	 * @return int Color index
365
-	 */
366
-	public function getClosestColor($R, $G = null, $B = null)
367
-	{
368
-		if (is_array($R)) {
369
-			return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']);
370
-		}
291
+        return $this->getColorRGB($tc);
292
+    }
293
+	
294
+    /**
295
+     * Returns a RGBA array for pixel at $x, $y
296
+     * 
297
+     * @param int $x
298
+     * @param int $y
299
+     * @return array RGB array 
300
+     */
301
+    public function getRGBAt($x, $y)
302
+    {
303
+        return $this->getColorRGB($this->getColorAt($x, $y));
304
+    }
305
+	
306
+    /**
307
+     * Writes a pixel at the designated coordinates
308
+     * 
309
+     * Takes an associative array of colours and uses getExactColor() to
310
+     * retrieve the exact index color to write to the image with.
311
+     *
312
+     * @param int $x
313
+     * @param int $y
314
+     * @param array $color
315
+     */
316
+    public function setRGBAt($x, $y, $color)
317
+    {
318
+        $this->setColorAt($x, $y, $this->getExactColor($color));
319
+    }
320
+	
321
+    /**
322
+     * Returns a color's RGB
323
+     * 
324
+     * @param int $colorIndex Color index
325
+     * @return mixed RGBA array for a color with index $colorIndex
326
+     */
327
+    public function getColorRGB($colorIndex)
328
+    {
329
+        return imageColorsForIndex($this->handle, $colorIndex);
330
+    }
331
+	
332
+    /**
333
+     * Returns an index of the color at $x, $y
334
+     * 
335
+     * @param int $x
336
+     * @param int $y
337
+     * @return int Color index for a pixel at $x, $y
338
+     */
339
+    public function getColorAt($x, $y)
340
+    {
341
+        return imagecolorat($this->handle, $x, $y);
342
+    }
343
+	
344
+    /**
345
+     * Set the color index $color to a pixel at $x, $y
346
+     * 
347
+     * @param int $x
348
+     * @param int $y
349
+     * @param int $color Color index
350
+     */
351
+    public function setColorAt($x, $y, $color)
352
+    {
353
+        return imagesetpixel($this->handle, $x, $y, $color);
354
+    }
355
+	
356
+    /**
357
+     * Returns closest color index that matches the given RGB value. Uses
358
+     * PHP's imagecolorclosest()
359
+     * 
360
+     * @param mixed $R Red or RGBA array
361
+     * @param int $G Green component (or null if $R is an RGB array)
362
+     * @param int $B Blue component (or null if $R is an RGB array)
363
+     * @return int Color index
364
+     */
365
+    public function getClosestColor($R, $G = null, $B = null)
366
+    {
367
+        if (is_array($R)) {
368
+            return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']);
369
+        }
371 370
 		
372
-		return imagecolorclosest($this->handle, $R, $G, $B);
373
-	}
374
-	
375
-	/**
376
-	 * Returns the color index that exactly matches the given RGB value. Uses
377
-	 * PHP's imagecolorexact()
378
-	 * 
379
-	 * @param mixed $R Red or RGBA array
380
-	 * @param int $G Green component (or null if $R is an RGB array)
381
-	 * @param int $B Blue component (or null if $R is an RGB array)
382
-	 * @return int Color index
383
-	 */
384
-	public function getExactColor($R, $G = null, $B = null)
385
-	{
386
-		if (is_array($R)) {
387
-			return imagecolorexact($this->handle, $R['red'], $R['green'], $R['blue']);
388
-		}
371
+        return imagecolorclosest($this->handle, $R, $G, $B);
372
+    }
373
+	
374
+    /**
375
+     * Returns the color index that exactly matches the given RGB value. Uses
376
+     * PHP's imagecolorexact()
377
+     * 
378
+     * @param mixed $R Red or RGBA array
379
+     * @param int $G Green component (or null if $R is an RGB array)
380
+     * @param int $B Blue component (or null if $R is an RGB array)
381
+     * @return int Color index
382
+     */
383
+    public function getExactColor($R, $G = null, $B = null)
384
+    {
385
+        if (is_array($R)) {
386
+            return imagecolorexact($this->handle, $R['red'], $R['green'], $R['blue']);
387
+        }
389 388
 		
390
-		return imagecolorexact($this->handle, $R, $G, $B);
391
-	}
392
-	
393
-	/**
394
-	 * Copies transparency information from $sourceImage. Optionally fills
395
-	 * the image with the transparent color at (0, 0).
396
-	 * 
397
-	 * @param object $sourceImage
398
-	 * @param bool $fill True if you want to fill the image with transparent color
399
-	 */
400
-	public function copyTransparencyFrom($sourceImage, $fill = true)
401
-	{
402
-		if ($sourceImage->isTransparent()) {
403
-			$rgba = $sourceImage->getTransparentColorRGB();
389
+        return imagecolorexact($this->handle, $R, $G, $B);
390
+    }
391
+	
392
+    /**
393
+     * Copies transparency information from $sourceImage. Optionally fills
394
+     * the image with the transparent color at (0, 0).
395
+     * 
396
+     * @param object $sourceImage
397
+     * @param bool $fill True if you want to fill the image with transparent color
398
+     */
399
+    public function copyTransparencyFrom($sourceImage, $fill = true)
400
+    {
401
+        if ($sourceImage->isTransparent()) {
402
+            $rgba = $sourceImage->getTransparentColorRGB();
404 403
 			
405
-			if ($rgba === null) {
406
-				return;
407
-			}
404
+            if ($rgba === null) {
405
+                return;
406
+            }
408 407
 			
409
-			if ($this->isTrueColor()) {
410
-				$rgba['alpha'] = 127;
411
-				$color = $this->allocateColorAlpha($rgba);
412
-			} else {
413
-				$color = $this->allocateColor($rgba);
414
-			}
408
+            if ($this->isTrueColor()) {
409
+                $rgba['alpha'] = 127;
410
+                $color = $this->allocateColorAlpha($rgba);
411
+            } else {
412
+                $color = $this->allocateColor($rgba);
413
+            }
415 414
 			
416
-			$this->setTransparentColor($color);
415
+            $this->setTransparentColor($color);
417 416
 			
418
-			if ($fill) {
419
-				$this->fill(0, 0, $color);
420
-			}
421
-		}
422
-	}
423
-	
424
-	/**
425
-	 * Fill the image at ($x, $y) with color index $color
426
-	 * 
427
-	 * @param int $x
428
-	 * @param int $y
429
-	 * @param int $color
430
-	 */
431
-	public function fill($x, $y, $color)
432
-	{
433
-		return imagefill($this->handle, $x, $y, $color);
434
-	}
435
-	
436
-	/**
437
-	 * Used internally to create Operation objects
438
-	 *
439
-	 * @param string $name
440
-	 * @return object
441
-	 */
442
-	protected function getOperation($name)
443
-	{
444
-		return OperationFactory::get($name);
445
-	}
446
-	
447
-	/**
448
-	 * Returns the image's mask
449
-	 * 
450
-	 * Mask is a greyscale image where the shade defines the alpha channel (black = transparent, white = opaque).
451
-	 * 
452
-	 * For opaque images (JPEG), the result will be white. For images with single-color transparency (GIF, 8-bit PNG), 
453
-	 * the areas with the transparent color will be black. For images with alpha channel transparenct, 
454
-	 * the result will be alpha channel.
455
-	 * 
456
-	 * @return \WideImage\Image An image mask
457
-	 **/
458
-	public function getMask()
459
-	{
460
-		return $this->getOperation('GetMask')->execute($this);
461
-	}
462
-	
463
-	/**
464
-	 * Resize the image to given dimensions.
465
-	 * 
466
-	 * $width and $height are both smart coordinates. This means that you can pass any of these values in:
467
-	 *   - positive or negative integer (100, -20, ...)
468
-	 *   - positive or negative percent string (30%, -15%, ...)
469
-	 *   - complex coordinate (50% - 20, 15 + 30%, ...)
470
-	 *   - null: if one dimension is null, it's calculated proportionally from the other.
471
-	 * 
472
-	 * $fit parameter can be set to one of these three values:
473
-	 *   - 'inside': resize proportionally and fit the resulting image tightly in the $width x $height box
474
-	 *   - 'outside': resize proportionally and fit the resulting image tighly outside the box
475
-	 *   - 'fill': resize the image to fill the $width x $height box exactly
476
-	 *
477
-	 * $scale parameter can be:
478
-	 *   - 'down': only resize the image if it's larger than the $width x $height box
479
-	 *   - 'up': only resize the image if it's smaller than the $width x $height box
480
-	 *   - 'any': resize the image
481
-	 *
482
-	 * Example (resize to half-size):
483
-	 * <code>
484
-	 * $smaller = $image->resize('50%');
485
-	 * 
486
-	 * $smaller = $image->resize('100', '100', 'inside', 'down');
487
-	 * is the same as
488
-	 * $smaller = $image->resizeDown(100, 100, 'inside');
489
-	 * </code>
490
-	 * 
491
-	 * @param mixed $width The new width (smart coordinate), or null.
492
-	 * @param mixed $height The new height (smart coordinate), or null.
493
-	 * @param string $fit 'inside', 'outside', 'fill'
494
-	 * @param string $scale 'down', 'up', 'any'
495
-	 * @return \WideImage\Image The resized image
496
-	 */
497
-	public function resize($width = null, $height = null, $fit = 'inside', $scale = 'any')
498
-	{
499
-		return $this->getOperation('Resize')->execute($this, $width, $height, $fit, $scale);
500
-	}
501
-	
502
-	/**
503
-	 * Same as \WideImage\Image::resize(), but the image is only applied if it is larger then the given dimensions.
504
-	 * Otherwise, the resulting image retains the source's dimensions.
505
-	 * 
506
-	 * @param int $width New width, smart coordinate
507
-	 * @param int $height New height, smart coordinate
508
-	 * @param string $fit 'inside', 'outside', 'fill'
509
-	 * @return \WideImage\Image resized image
510
-	 */
511
-	public function resizeDown($width = null, $height = null, $fit = 'inside')
512
-	{
513
-		return $this->resize($width, $height, $fit, 'down');
514
-	}
515
-	
516
-	/**
517
-	 * Same as \WideImage\Image::resize(), but the image is only applied if it is smaller then the given dimensions.
518
-	 * Otherwise, the resulting image retains the source's dimensions.
519
-	 * 
520
-	 * @param int $width New width, smart coordinate
521
-	 * @param int $height New height, smart coordinate
522
-	 * @param string $fit 'inside', 'outside', 'fill'
523
-	 * @return \WideImage\Image resized image
524
-	 */
525
-	public function resizeUp($width = null, $height = null, $fit = 'inside')
526
-	{
527
-		return $this->resize($width, $height, $fit, 'up');
528
-	}
529
-	
530
-	/**
531
-	 * Rotate the image for angle $angle clockwise.
532
-	 * 
533
-	 * Preserves transparency. Has issues when saving to a BMP.
534
-	 * 
535
-	 * @param int $angle Angle in degrees, clock-wise
536
-	 * @param int $bgColor color of the new background
537
-	 * @param bool $ignoreTransparent
538
-	 * @return \WideImage\Image The rotated image
539
-	 */
540
-	public function rotate($angle, $bgColor = null, $ignoreTransparent = true)
541
-	{
542
-		return $this->getOperation('Rotate')->execute($this, $angle, $bgColor, $ignoreTransparent);
543
-	}
544
-	
545
-	/**
546
-	 * This method lays the overlay (watermark) on the image.
547
-	 * 
548
-	 * Hint: if the overlay is a truecolor image with alpha channel, you should leave $pct at 100.
549
-	 * 
550
-	 * This operation supports alignment notation in coordinates:
551
-	 * <code>
552
-	 * $watermark = WideImage::load('logo.gif');
553
-	 * $base = WideImage::load('picture.jpg');
554
-	 * $result = $base->merge($watermark, "right - 10", "bottom - 10", 50);
555
-	 * // applies a logo aligned to bottom-right corner with a 10 pixel margin
556
-	 * </code>
557
-	 * 
558
-	 * @param \WideImage\Image $overlay The overlay image
559
-	 * @param mixed $left Left position of the overlay, smart coordinate
560
-	 * @param mixed $top Top position of the overlay, smart coordinate
561
-	 * @param int $pct The opacity of the overlay
562
-	 * @return \WideImage\Image The merged image
563
-	 */
564
-	public function merge($overlay, $left = 0, $top = 0, $pct = 100)
565
-	{
566
-		return $this->getOperation('Merge')->execute($this, $overlay, $left, $top, $pct);
567
-	}
568
-	
569
-	/**
570
-	 * Resizes the canvas of the image, but doesn't scale the content of the image
571
-	 * 
572
-	 * This operation creates an empty canvas with dimensions $width x $height, filled with 
573
-	 * background color $bg_color and draws the original image onto it at position [$pos_x, $pos_y].
574
-	 * 
575
-	 * Arguments $width, $height, $pos_x and $pos_y are all smart coordinates. $width and $height are 
576
-	 * relative to the current image size, $pos_x and $pos_y are relative to the newly calculated
577
-	 * canvas size. This can be confusing, but it makes sense. See the example below.
578
-	 * 
579
-	 * The example below loads a 100x150 image and then resizes its canvas to 200% x 100%+20 
580
-	 * (which evaluates to 200x170). The image is placed at position [10, center+20], which evaluates to [10, 30].
581
-	 * <code>
582
-	 * $image = WideImage::load('someimage.jpg'); // 100x150
583
-	 * $white = $image->allocateColor(255, 255, 255);
584
-	 * $image->resizeCanvas('200%', '100% + 20', 10, 'center+20', $white);
585
-	 * </code>
586
-	 * 
587
-	 * The parameter $merge defines whether the original image should be merged onto the new canvas.
588
-	 * This means it blends transparent color and alpha colors into the background color. If set to false,
589
-	 * the original image is just copied over, preserving the transparency/alpha information.
590
-	 * 
591
-	 * You can set the $scale parameter to limit when to resize the canvas. For example, if you want 
592
-	 * to resize the canvas only if the image is smaller than the new size, but leave the image intact 
593
-	 * if it's larger, set it to 'up'. Likewise, if you want to shrink the canvas, but don't want to 
594
-	 * change images that are already smaller, set it to 'down'. 
595
-	 * 
596
-	 * @param mixed $width Width of the new canvas (smart coordinate, relative to current image width)
597
-	 * @param mixed $height Height of the new canvas (smart coordinate, relative to current image height)
598
-	 * @param mixed $pos_x x-position of the image (smart coordinate, relative to the new width)
599
-	 * @param mixed $pos_y y-position of the image (smart coordinate, relative to the new height)
600
-	 * @param int $bg_color Background color (created with allocateColor or allocateColorAlpha), defaults to null (tries to use a transparent color)
601
-	 * @param string $scale Possible values: 'up' (enlarge only), 'down' (downsize only), 'any' (resize precisely to $width x $height). Defaults to 'any'.
602
-	 * @param bool $merge Merge the original image (flatten alpha channel and transparency) or copy it over (preserve). Defaults to false.
603
-	 * @return \WideImage\Image The resulting image with resized canvas
604
-	 */
605
-	public function resizeCanvas($width, $height, $pos_x, $pos_y, $bg_color = null, $scale = 'any', $merge = false)
606
-	{
607
-		return $this->getOperation('ResizeCanvas')->execute($this, $width, $height, $pos_x, $pos_y, $bg_color, $scale, $merge);
608
-	}
609
-	
610
-	/**
611
-	 * Returns an image with round corners
612
-	 * 
613
-	 * You can either set the corners' color or set them transparent.
614
-	 * 
615
-	 * Note on $smoothness: 1 means jagged edges, 2 is much better, more than 4 doesn't noticeably improve the quality.
616
-	 * Rendering becomes increasingly slower if you increase smoothness.
617
-	 * 
618
-	 * Example:
619
-	 * <code>
620
-	 * $nice = $ugly->roundCorners(20, $ugly->allocateColor(255, 0, 0), 2);
621
-	 * </code>
622
-	 * 
623
-	 * Use $corners parameter to specify which corners to draw rounded. Possible values are
624
-	 * WideImage::SIDE_TOP_LEFT, WideImage::SIDE_TOP,
625
-	 * WideImage::SIDE_TOP_RIGHT, WideImage::SIDE_RIGHT,
626
-	 * WideImage::SIDE_BOTTOM_RIGHT, WideImage::SIDE_BOTTOM, 
627
-	 * WideImage::SIDE_BOTTOM_LEFT, WideImage::SIDE_LEFT, and WideImage::SIDE_ALL.
628
-	 * You can specify any combination of corners with a + operation, see example below.
629
-	 * 
630
-	 * Example:
631
-	 * <code>
632
-	 * $white = $image->allocateColor(255, 255, 255);
633
-	 * $diagonal_corners = $image->roundCorners(15, $white, 2, WideImage::SIDE_TOP_LEFT + WideImage::SIDE_BOTTOM_RIGHT);
634
-	 * $right_corners = $image->roundCorners(15, $white, 2, WideImage::SIDE_RIGHT);
635
-	 * </code>
636
-	 * 
637
-	 * @param int $radius Radius of the corners
638
-	 * @param int $color The color of corners. If null, corners are rendered transparent (slower than using a solid color).
639
-	 * @param int $smoothness Specify the level of smoothness. Suggested values from 1 to 4.
640
-	 * @param int $corners Specify which corners to draw (defaults to WideImage::SIDE_ALL = all corners)
641
-	 * @return \WideImage\Image The resulting image with round corners
642
-	 */
643
-	public function roundCorners($radius, $color = null, $smoothness = 2, $corners = 255)
644
-	{
645
-		return $this->getOperation('RoundCorners')->execute($this, $radius, $color, $smoothness, $corners);
646
-	}
647
-	
648
-	/**
649
-	 * Returns an image with applied mask
650
-	 * 
651
-	 * A mask is a grayscale image, where the shade determines the alpha channel. Black is fully transparent
652
-	 * and white is fully opaque.
653
-	 * 
654
-	 * @param \WideImage\Image $mask The mask image, greyscale
655
-	 * @param mixed $left Left coordinate, smart coordinate
656
-	 * @param mixed $top Top coordinate, smart coordinate
657
-	 * @return \WideImage\Image The resulting image
658
-	 **/
659
-	public function applyMask($mask, $left = 0, $top = 0)
660
-	{
661
-		return $this->getOperation('ApplyMask')->execute($this, $mask, $left, $top);
662
-	}
663
-	
664
-	/**
665
-	 * Applies a filter
666
-	 *
667
-	 * @param int $filter One of the IMG_FILTER_* constants
668
-	 * @param int $arg1
669
-	 * @param int $arg2
670
-	 * @param int $arg3
671
-	 * @param int $arg4
672
-	 * @return \WideImage\Image
673
-	 */
674
-	public function applyFilter($filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null)
675
-	{
676
-		return $this->getOperation('ApplyFilter')->execute($this, $filter, $arg1, $arg2, $arg3, $arg4);
677
-	}
678
-	
679
-	/**
680
-	 * Applies convolution matrix with imageconvolution()
681
-	 *
682
-	 * @param array $matrix
683
-	 * @param float $div
684
-	 * @param float $offset
685
-	 * @return \WideImage\Image
686
-	 */
687
-	public function applyConvolution($matrix, $div, $offset)
688
-	{
689
-		return $this->getOperation('ApplyConvolution')->execute($this, $matrix, $div, $offset);
690
-	}
691
-	
692
-	/**
693
-	 * Returns a cropped rectangular portion of the image
694
-	 * 
695
-	 * If the rectangle specifies area that is out of bounds, it's limited to the current image bounds.
696
-	 * 
697
-	 * Examples:
698
-	 * <code>
699
-	 * $cropped = $img->crop(10, 10, 150, 200); // crops a 150x200 rect at (10, 10)
700
-	 * $cropped = $img->crop(-100, -50, 100, 50); // crops a 100x50 rect at the right-bottom of the image
701
-	 * $cropped = $img->crop('25%', '25%', '50%', '50%'); // crops a 50%x50% rect from the center of the image
702
-	 * </code>
703
-	 * 
704
-	 * This operation supports alignment notation in left/top coordinates.
705
-	 * Example:
706
-	 * <code>
707
-	 * $cropped = $img->crop("right", "bottom", 100, 200); // crops a 100x200 rect from right bottom
708
-	 * $cropped = $img->crop("center", "middle", 50, 30); // crops a 50x30 from the center of the image
709
-	 * </code>
710
-	 * 
711
-	 * @param mixed $left Left-coordinate of the crop rect, smart coordinate
712
-	 * @param mixed $top Top-coordinate of the crop rect, smart coordinate
713
-	 * @param mixed $width Width of the crop rect, smart coordinate
714
-	 * @param mixed $height Height of the crop rect, smart coordinate
715
-	 * @return \WideImage\Image The cropped image
716
-	 **/
717
-	public function crop($left = 0, $top = 0, $width = '100%', $height = '100%')
718
-	{
719
-		return $this->getOperation('Crop')->execute($this, $left, $top, $width, $height);
720
-	}
721
-	
722
-	/**
723
-	 * Performs an auto-crop on the image
724
-	 *
725
-	 * The image is auto-cropped from each of four sides. All sides are 
726
-	 * scanned for pixels that differ from $base_color for more than 
727
-	 * $rgb_threshold in absolute RGB difference. If more than $pixel_cutoff 
728
-	 * differentiating pixels are found, that line is considered to be the crop line for the side.
729
-	 * If the line isn't different enough, the algorithm procedes to the next line 
730
-	 * towards the other edge of the image.
731
-	 * 
732
-	 * When the crop rectangle is found, it's enlarged by the $margin value on each of the four sides.
733
-	 *
734
-	 * @param int $margin Margin for the crop rectangle, can be negative.
735
-	 * @param int $rgb_threshold RGB difference which still counts as "same color".
736
-	 * @param int $pixel_cutoff How many pixels need to be different to mark a cut line.
737
-	 * @param int $base_color The base color index. If none specified (or null given), left-top pixel is used.
738
-	 * @return \WideImage\Image The cropped image
739
-	 */
740
-	public function autoCrop($margin = 0, $rgb_threshold = 0, $pixel_cutoff = 1, $base_color = null)
741
-	{
742
-		return $this->getOperation('AutoCrop')->execute($this, $margin, $rgb_threshold, $pixel_cutoff, $base_color);
743
-	}
744
-	
745
-	/**
746
-	 * Returns a negative of the image
747
-	 *
748
-	 * This operation differs from calling \WideImage\Image::applyFilter(IMG_FILTER_NEGATIVE), because it's 8-bit and transparency safe.
749
-	 * This means it will return an 8-bit image, if the source image is 8-bit. If that 8-bit image has a palette transparency,
750
-	 * the resulting image will keep transparency.
751
-	 *
752
-	 * @return \WideImage\Image negative of the image
753
-	 */
754
-	public function asNegative()
755
-	{
756
-		return $this->getOperation('AsNegative')->execute($this);
757
-	}
758
-	
759
-	/**
760
-	 * Returns a grayscale copy of the image
761
-	 * 
762
-	 * @return \WideImage\Image grayscale copy
763
-	 **/
764
-	public function asGrayscale()
765
-	{
766
-		return $this->getOperation('AsGrayscale')->execute($this);
767
-	}
768
-	
769
-	/**
770
-	 * Returns a mirrored copy of the image
771
-	 * 
772
-	 * @return \WideImage\Image Mirrored copy
773
-	 **/
774
-	public function mirror()
775
-	{
776
-		return $this->getOperation('Mirror')->execute($this);
777
-	}
778
-	
779
-	/**
780
-	 * Applies the unsharp filter
781
-	 * 
782
-	 * @param float $amount
783
-	 * @param float $radius
784
-	 * @param float $threshold
785
-	 * @return \WideImage\Image Unsharpened copy of the image
786
-	 **/
787
-	public function unsharp($amount, $radius, $threshold)
788
-	{
789
-		return $this->getOperation('Unsharp')->execute($this, $amount, $radius, $threshold);
790
-	}
791
-	
792
-	/**
793
-	 * Returns a flipped (mirrored over horizontal line) copy of the image
794
-	 * 
795
-	 * @return \WideImage\Image Flipped copy
796
-	 **/
797
-	public function flip()
798
-	{
799
-		return $this->getOperation('Flip')->execute($this);
800
-	}
801
-	
802
-	/**
803
-	 * Corrects gamma on the image
804
-	 * 
805
-	 * @param float $inputGamma
806
-	 * @param float $outputGamma
807
-	 * @return \WideImage\Image Image with corrected gamma
808
-	 **/
809
-	public function correctGamma($inputGamma, $outputGamma)
810
-	{
811
-		return $this->getOperation('CorrectGamma')->execute($this, $inputGamma, $outputGamma);
812
-	}
813
-	
814
-	/**
815
-	 * Adds noise to the image
816
-	 * 
817
-	 * @author Tomasz Kapusta
818
-	 * 
819
-	 * @param int $amount Number of noise pixels to add
820
-	 * @param string $type Type of noise 'salt&pepper', 'color' or 'mono'
821
-	 * @return \WideImage\Image Image with noise added
822
-	 **/
823
-	public function addNoise($amount, $type)
824
-	{
825
-		return $this->getOperation('AddNoise')->execute($this, $amount, $type);
826
-	}
827
-	
828
-	/**
829
-	 * Used internally to execute operations
830
-	 *
831
-	 * @param string $name
832
-	 * @param array $args
833
-	 * @return \WideImage\Image
834
-	 */
835
-	public function __call($name, $args)
836
-	{
837
-		$op = $this->getOperation($name);
838
-		array_unshift($args, $this);
839
-		return call_user_func_array(array($op, 'execute'), $args);
840
-	}
841
-	
842
-	/**
843
-	 * Returns an image in GIF or PNG format
844
-	 *
845
-	 * @return string
846
-	 */
847
-	public function __toString()
848
-	{
849
-		if ($this->isTransparent()) {
850
-			return $this->asString('gif');
851
-		}
417
+            if ($fill) {
418
+                $this->fill(0, 0, $color);
419
+            }
420
+        }
421
+    }
422
+	
423
+    /**
424
+     * Fill the image at ($x, $y) with color index $color
425
+     * 
426
+     * @param int $x
427
+     * @param int $y
428
+     * @param int $color
429
+     */
430
+    public function fill($x, $y, $color)
431
+    {
432
+        return imagefill($this->handle, $x, $y, $color);
433
+    }
434
+	
435
+    /**
436
+     * Used internally to create Operation objects
437
+     *
438
+     * @param string $name
439
+     * @return object
440
+     */
441
+    protected function getOperation($name)
442
+    {
443
+        return OperationFactory::get($name);
444
+    }
445
+	
446
+    /**
447
+     * Returns the image's mask
448
+     * 
449
+     * Mask is a greyscale image where the shade defines the alpha channel (black = transparent, white = opaque).
450
+     * 
451
+     * For opaque images (JPEG), the result will be white. For images with single-color transparency (GIF, 8-bit PNG), 
452
+     * the areas with the transparent color will be black. For images with alpha channel transparenct, 
453
+     * the result will be alpha channel.
454
+     * 
455
+     * @return \WideImage\Image An image mask
456
+     **/
457
+    public function getMask()
458
+    {
459
+        return $this->getOperation('GetMask')->execute($this);
460
+    }
461
+	
462
+    /**
463
+     * Resize the image to given dimensions.
464
+     * 
465
+     * $width and $height are both smart coordinates. This means that you can pass any of these values in:
466
+     *   - positive or negative integer (100, -20, ...)
467
+     *   - positive or negative percent string (30%, -15%, ...)
468
+     *   - complex coordinate (50% - 20, 15 + 30%, ...)
469
+     *   - null: if one dimension is null, it's calculated proportionally from the other.
470
+     * 
471
+     * $fit parameter can be set to one of these three values:
472
+     *   - 'inside': resize proportionally and fit the resulting image tightly in the $width x $height box
473
+     *   - 'outside': resize proportionally and fit the resulting image tighly outside the box
474
+     *   - 'fill': resize the image to fill the $width x $height box exactly
475
+     *
476
+     * $scale parameter can be:
477
+     *   - 'down': only resize the image if it's larger than the $width x $height box
478
+     *   - 'up': only resize the image if it's smaller than the $width x $height box
479
+     *   - 'any': resize the image
480
+     *
481
+     * Example (resize to half-size):
482
+     * <code>
483
+     * $smaller = $image->resize('50%');
484
+     * 
485
+     * $smaller = $image->resize('100', '100', 'inside', 'down');
486
+     * is the same as
487
+     * $smaller = $image->resizeDown(100, 100, 'inside');
488
+     * </code>
489
+     * 
490
+     * @param mixed $width The new width (smart coordinate), or null.
491
+     * @param mixed $height The new height (smart coordinate), or null.
492
+     * @param string $fit 'inside', 'outside', 'fill'
493
+     * @param string $scale 'down', 'up', 'any'
494
+     * @return \WideImage\Image The resized image
495
+     */
496
+    public function resize($width = null, $height = null, $fit = 'inside', $scale = 'any')
497
+    {
498
+        return $this->getOperation('Resize')->execute($this, $width, $height, $fit, $scale);
499
+    }
500
+	
501
+    /**
502
+     * Same as \WideImage\Image::resize(), but the image is only applied if it is larger then the given dimensions.
503
+     * Otherwise, the resulting image retains the source's dimensions.
504
+     * 
505
+     * @param int $width New width, smart coordinate
506
+     * @param int $height New height, smart coordinate
507
+     * @param string $fit 'inside', 'outside', 'fill'
508
+     * @return \WideImage\Image resized image
509
+     */
510
+    public function resizeDown($width = null, $height = null, $fit = 'inside')
511
+    {
512
+        return $this->resize($width, $height, $fit, 'down');
513
+    }
514
+	
515
+    /**
516
+     * Same as \WideImage\Image::resize(), but the image is only applied if it is smaller then the given dimensions.
517
+     * Otherwise, the resulting image retains the source's dimensions.
518
+     * 
519
+     * @param int $width New width, smart coordinate
520
+     * @param int $height New height, smart coordinate
521
+     * @param string $fit 'inside', 'outside', 'fill'
522
+     * @return \WideImage\Image resized image
523
+     */
524
+    public function resizeUp($width = null, $height = null, $fit = 'inside')
525
+    {
526
+        return $this->resize($width, $height, $fit, 'up');
527
+    }
528
+	
529
+    /**
530
+     * Rotate the image for angle $angle clockwise.
531
+     * 
532
+     * Preserves transparency. Has issues when saving to a BMP.
533
+     * 
534
+     * @param int $angle Angle in degrees, clock-wise
535
+     * @param int $bgColor color of the new background
536
+     * @param bool $ignoreTransparent
537
+     * @return \WideImage\Image The rotated image
538
+     */
539
+    public function rotate($angle, $bgColor = null, $ignoreTransparent = true)
540
+    {
541
+        return $this->getOperation('Rotate')->execute($this, $angle, $bgColor, $ignoreTransparent);
542
+    }
543
+	
544
+    /**
545
+     * This method lays the overlay (watermark) on the image.
546
+     * 
547
+     * Hint: if the overlay is a truecolor image with alpha channel, you should leave $pct at 100.
548
+     * 
549
+     * This operation supports alignment notation in coordinates:
550
+     * <code>
551
+     * $watermark = WideImage::load('logo.gif');
552
+     * $base = WideImage::load('picture.jpg');
553
+     * $result = $base->merge($watermark, "right - 10", "bottom - 10", 50);
554
+     * // applies a logo aligned to bottom-right corner with a 10 pixel margin
555
+     * </code>
556
+     * 
557
+     * @param \WideImage\Image $overlay The overlay image
558
+     * @param mixed $left Left position of the overlay, smart coordinate
559
+     * @param mixed $top Top position of the overlay, smart coordinate
560
+     * @param int $pct The opacity of the overlay
561
+     * @return \WideImage\Image The merged image
562
+     */
563
+    public function merge($overlay, $left = 0, $top = 0, $pct = 100)
564
+    {
565
+        return $this->getOperation('Merge')->execute($this, $overlay, $left, $top, $pct);
566
+    }
567
+	
568
+    /**
569
+     * Resizes the canvas of the image, but doesn't scale the content of the image
570
+     * 
571
+     * This operation creates an empty canvas with dimensions $width x $height, filled with 
572
+     * background color $bg_color and draws the original image onto it at position [$pos_x, $pos_y].
573
+     * 
574
+     * Arguments $width, $height, $pos_x and $pos_y are all smart coordinates. $width and $height are 
575
+     * relative to the current image size, $pos_x and $pos_y are relative to the newly calculated
576
+     * canvas size. This can be confusing, but it makes sense. See the example below.
577
+     * 
578
+     * The example below loads a 100x150 image and then resizes its canvas to 200% x 100%+20 
579
+     * (which evaluates to 200x170). The image is placed at position [10, center+20], which evaluates to [10, 30].
580
+     * <code>
581
+     * $image = WideImage::load('someimage.jpg'); // 100x150
582
+     * $white = $image->allocateColor(255, 255, 255);
583
+     * $image->resizeCanvas('200%', '100% + 20', 10, 'center+20', $white);
584
+     * </code>
585
+     * 
586
+     * The parameter $merge defines whether the original image should be merged onto the new canvas.
587
+     * This means it blends transparent color and alpha colors into the background color. If set to false,
588
+     * the original image is just copied over, preserving the transparency/alpha information.
589
+     * 
590
+     * You can set the $scale parameter to limit when to resize the canvas. For example, if you want 
591
+     * to resize the canvas only if the image is smaller than the new size, but leave the image intact 
592
+     * if it's larger, set it to 'up'. Likewise, if you want to shrink the canvas, but don't want to 
593
+     * change images that are already smaller, set it to 'down'. 
594
+     * 
595
+     * @param mixed $width Width of the new canvas (smart coordinate, relative to current image width)
596
+     * @param mixed $height Height of the new canvas (smart coordinate, relative to current image height)
597
+     * @param mixed $pos_x x-position of the image (smart coordinate, relative to the new width)
598
+     * @param mixed $pos_y y-position of the image (smart coordinate, relative to the new height)
599
+     * @param int $bg_color Background color (created with allocateColor or allocateColorAlpha), defaults to null (tries to use a transparent color)
600
+     * @param string $scale Possible values: 'up' (enlarge only), 'down' (downsize only), 'any' (resize precisely to $width x $height). Defaults to 'any'.
601
+     * @param bool $merge Merge the original image (flatten alpha channel and transparency) or copy it over (preserve). Defaults to false.
602
+     * @return \WideImage\Image The resulting image with resized canvas
603
+     */
604
+    public function resizeCanvas($width, $height, $pos_x, $pos_y, $bg_color = null, $scale = 'any', $merge = false)
605
+    {
606
+        return $this->getOperation('ResizeCanvas')->execute($this, $width, $height, $pos_x, $pos_y, $bg_color, $scale, $merge);
607
+    }
608
+	
609
+    /**
610
+     * Returns an image with round corners
611
+     * 
612
+     * You can either set the corners' color or set them transparent.
613
+     * 
614
+     * Note on $smoothness: 1 means jagged edges, 2 is much better, more than 4 doesn't noticeably improve the quality.
615
+     * Rendering becomes increasingly slower if you increase smoothness.
616
+     * 
617
+     * Example:
618
+     * <code>
619
+     * $nice = $ugly->roundCorners(20, $ugly->allocateColor(255, 0, 0), 2);
620
+     * </code>
621
+     * 
622
+     * Use $corners parameter to specify which corners to draw rounded. Possible values are
623
+     * WideImage::SIDE_TOP_LEFT, WideImage::SIDE_TOP,
624
+     * WideImage::SIDE_TOP_RIGHT, WideImage::SIDE_RIGHT,
625
+     * WideImage::SIDE_BOTTOM_RIGHT, WideImage::SIDE_BOTTOM, 
626
+     * WideImage::SIDE_BOTTOM_LEFT, WideImage::SIDE_LEFT, and WideImage::SIDE_ALL.
627
+     * You can specify any combination of corners with a + operation, see example below.
628
+     * 
629
+     * Example:
630
+     * <code>
631
+     * $white = $image->allocateColor(255, 255, 255);
632
+     * $diagonal_corners = $image->roundCorners(15, $white, 2, WideImage::SIDE_TOP_LEFT + WideImage::SIDE_BOTTOM_RIGHT);
633
+     * $right_corners = $image->roundCorners(15, $white, 2, WideImage::SIDE_RIGHT);
634
+     * </code>
635
+     * 
636
+     * @param int $radius Radius of the corners
637
+     * @param int $color The color of corners. If null, corners are rendered transparent (slower than using a solid color).
638
+     * @param int $smoothness Specify the level of smoothness. Suggested values from 1 to 4.
639
+     * @param int $corners Specify which corners to draw (defaults to WideImage::SIDE_ALL = all corners)
640
+     * @return \WideImage\Image The resulting image with round corners
641
+     */
642
+    public function roundCorners($radius, $color = null, $smoothness = 2, $corners = 255)
643
+    {
644
+        return $this->getOperation('RoundCorners')->execute($this, $radius, $color, $smoothness, $corners);
645
+    }
646
+	
647
+    /**
648
+     * Returns an image with applied mask
649
+     * 
650
+     * A mask is a grayscale image, where the shade determines the alpha channel. Black is fully transparent
651
+     * and white is fully opaque.
652
+     * 
653
+     * @param \WideImage\Image $mask The mask image, greyscale
654
+     * @param mixed $left Left coordinate, smart coordinate
655
+     * @param mixed $top Top coordinate, smart coordinate
656
+     * @return \WideImage\Image The resulting image
657
+     **/
658
+    public function applyMask($mask, $left = 0, $top = 0)
659
+    {
660
+        return $this->getOperation('ApplyMask')->execute($this, $mask, $left, $top);
661
+    }
662
+	
663
+    /**
664
+     * Applies a filter
665
+     *
666
+     * @param int $filter One of the IMG_FILTER_* constants
667
+     * @param int $arg1
668
+     * @param int $arg2
669
+     * @param int $arg3
670
+     * @param int $arg4
671
+     * @return \WideImage\Image
672
+     */
673
+    public function applyFilter($filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null)
674
+    {
675
+        return $this->getOperation('ApplyFilter')->execute($this, $filter, $arg1, $arg2, $arg3, $arg4);
676
+    }
677
+	
678
+    /**
679
+     * Applies convolution matrix with imageconvolution()
680
+     *
681
+     * @param array $matrix
682
+     * @param float $div
683
+     * @param float $offset
684
+     * @return \WideImage\Image
685
+     */
686
+    public function applyConvolution($matrix, $div, $offset)
687
+    {
688
+        return $this->getOperation('ApplyConvolution')->execute($this, $matrix, $div, $offset);
689
+    }
690
+	
691
+    /**
692
+     * Returns a cropped rectangular portion of the image
693
+     * 
694
+     * If the rectangle specifies area that is out of bounds, it's limited to the current image bounds.
695
+     * 
696
+     * Examples:
697
+     * <code>
698
+     * $cropped = $img->crop(10, 10, 150, 200); // crops a 150x200 rect at (10, 10)
699
+     * $cropped = $img->crop(-100, -50, 100, 50); // crops a 100x50 rect at the right-bottom of the image
700
+     * $cropped = $img->crop('25%', '25%', '50%', '50%'); // crops a 50%x50% rect from the center of the image
701
+     * </code>
702
+     * 
703
+     * This operation supports alignment notation in left/top coordinates.
704
+     * Example:
705
+     * <code>
706
+     * $cropped = $img->crop("right", "bottom", 100, 200); // crops a 100x200 rect from right bottom
707
+     * $cropped = $img->crop("center", "middle", 50, 30); // crops a 50x30 from the center of the image
708
+     * </code>
709
+     * 
710
+     * @param mixed $left Left-coordinate of the crop rect, smart coordinate
711
+     * @param mixed $top Top-coordinate of the crop rect, smart coordinate
712
+     * @param mixed $width Width of the crop rect, smart coordinate
713
+     * @param mixed $height Height of the crop rect, smart coordinate
714
+     * @return \WideImage\Image The cropped image
715
+     **/
716
+    public function crop($left = 0, $top = 0, $width = '100%', $height = '100%')
717
+    {
718
+        return $this->getOperation('Crop')->execute($this, $left, $top, $width, $height);
719
+    }
720
+	
721
+    /**
722
+     * Performs an auto-crop on the image
723
+     *
724
+     * The image is auto-cropped from each of four sides. All sides are 
725
+     * scanned for pixels that differ from $base_color for more than 
726
+     * $rgb_threshold in absolute RGB difference. If more than $pixel_cutoff 
727
+     * differentiating pixels are found, that line is considered to be the crop line for the side.
728
+     * If the line isn't different enough, the algorithm procedes to the next line 
729
+     * towards the other edge of the image.
730
+     * 
731
+     * When the crop rectangle is found, it's enlarged by the $margin value on each of the four sides.
732
+     *
733
+     * @param int $margin Margin for the crop rectangle, can be negative.
734
+     * @param int $rgb_threshold RGB difference which still counts as "same color".
735
+     * @param int $pixel_cutoff How many pixels need to be different to mark a cut line.
736
+     * @param int $base_color The base color index. If none specified (or null given), left-top pixel is used.
737
+     * @return \WideImage\Image The cropped image
738
+     */
739
+    public function autoCrop($margin = 0, $rgb_threshold = 0, $pixel_cutoff = 1, $base_color = null)
740
+    {
741
+        return $this->getOperation('AutoCrop')->execute($this, $margin, $rgb_threshold, $pixel_cutoff, $base_color);
742
+    }
743
+	
744
+    /**
745
+     * Returns a negative of the image
746
+     *
747
+     * This operation differs from calling \WideImage\Image::applyFilter(IMG_FILTER_NEGATIVE), because it's 8-bit and transparency safe.
748
+     * This means it will return an 8-bit image, if the source image is 8-bit. If that 8-bit image has a palette transparency,
749
+     * the resulting image will keep transparency.
750
+     *
751
+     * @return \WideImage\Image negative of the image
752
+     */
753
+    public function asNegative()
754
+    {
755
+        return $this->getOperation('AsNegative')->execute($this);
756
+    }
757
+	
758
+    /**
759
+     * Returns a grayscale copy of the image
760
+     * 
761
+     * @return \WideImage\Image grayscale copy
762
+     **/
763
+    public function asGrayscale()
764
+    {
765
+        return $this->getOperation('AsGrayscale')->execute($this);
766
+    }
767
+	
768
+    /**
769
+     * Returns a mirrored copy of the image
770
+     * 
771
+     * @return \WideImage\Image Mirrored copy
772
+     **/
773
+    public function mirror()
774
+    {
775
+        return $this->getOperation('Mirror')->execute($this);
776
+    }
777
+	
778
+    /**
779
+     * Applies the unsharp filter
780
+     * 
781
+     * @param float $amount
782
+     * @param float $radius
783
+     * @param float $threshold
784
+     * @return \WideImage\Image Unsharpened copy of the image
785
+     **/
786
+    public function unsharp($amount, $radius, $threshold)
787
+    {
788
+        return $this->getOperation('Unsharp')->execute($this, $amount, $radius, $threshold);
789
+    }
790
+	
791
+    /**
792
+     * Returns a flipped (mirrored over horizontal line) copy of the image
793
+     * 
794
+     * @return \WideImage\Image Flipped copy
795
+     **/
796
+    public function flip()
797
+    {
798
+        return $this->getOperation('Flip')->execute($this);
799
+    }
800
+	
801
+    /**
802
+     * Corrects gamma on the image
803
+     * 
804
+     * @param float $inputGamma
805
+     * @param float $outputGamma
806
+     * @return \WideImage\Image Image with corrected gamma
807
+     **/
808
+    public function correctGamma($inputGamma, $outputGamma)
809
+    {
810
+        return $this->getOperation('CorrectGamma')->execute($this, $inputGamma, $outputGamma);
811
+    }
812
+	
813
+    /**
814
+     * Adds noise to the image
815
+     * 
816
+     * @author Tomasz Kapusta
817
+     * 
818
+     * @param int $amount Number of noise pixels to add
819
+     * @param string $type Type of noise 'salt&pepper', 'color' or 'mono'
820
+     * @return \WideImage\Image Image with noise added
821
+     **/
822
+    public function addNoise($amount, $type)
823
+    {
824
+        return $this->getOperation('AddNoise')->execute($this, $amount, $type);
825
+    }
826
+	
827
+    /**
828
+     * Used internally to execute operations
829
+     *
830
+     * @param string $name
831
+     * @param array $args
832
+     * @return \WideImage\Image
833
+     */
834
+    public function __call($name, $args)
835
+    {
836
+        $op = $this->getOperation($name);
837
+        array_unshift($args, $this);
838
+        return call_user_func_array(array($op, 'execute'), $args);
839
+    }
840
+	
841
+    /**
842
+     * Returns an image in GIF or PNG format
843
+     *
844
+     * @return string
845
+     */
846
+    public function __toString()
847
+    {
848
+        if ($this->isTransparent()) {
849
+            return $this->asString('gif');
850
+        }
852 851
 		
853
-		return $this->asString('png');
854
-	}
855
-	
856
-	/**
857
-	 * Returns a copy of the image object
858
-	 * 
859
-	 * @return \WideImage\Image The copy
860
-	 **/
861
-	public function copy()
862
-	{
863
-		$dest = $this->doCreate($this->getWidth(), $this->getHeight());
864
-		$dest->copyTransparencyFrom($this, true);
865
-		$this->copyTo($dest, 0, 0);
866
-		return $dest;
867
-	}
868
-	
869
-	/**
870
-	 * Copies this image onto another image
871
-	 * 
872
-	 * @param \WideImage\Image $dest
873
-	 * @param int $left
874
-	 * @param int $top
875
-	 **/
876
-	public function copyTo($dest, $left = 0, $top = 0)
877
-	{
878
-		if (!imagecopy($dest->getHandle(), $this->handle, $left, $top, 0, 0, $this->getWidth(), $this->getHeight())) {
879
-			throw new GDFunctionResultException("imagecopy() returned false");
880
-		}
881
-	}
882
-	
883
-	/**
884
-	 * Returns the canvas object
885
-	 * 
886
-	 * The Canvas object can be used to draw text and shapes on the image
887
-	 * 
888
-	 * Examples:
889
-	 * <code>
890
-	 * $img = WideImage::load('pic.jpg);
891
-	 * $canvas = $img->getCanvas();
892
-	 * $canvas->useFont('arial.ttf', 15, $img->allocateColor(200, 220, 255));
893
-	 * $canvas->writeText(10, 50, "Hello world!");
894
-	 * 
895
-	 * $canvas->filledRectangle(10, 10, 80, 40, $img->allocateColor(255, 127, 255));
896
-	 * $canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0));
897
-	 * $img->saveToFile('new.png');
898
-	 * </code>
899
-	 * 
900
-	 * @return \WideImage\Canvas The Canvas object
901
-	 **/
902
-	function getCanvas()
903
-	{
904
-		if ($this->canvas == null) {
905
-			$this->canvas = new Canvas($this);
906
-		}
852
+        return $this->asString('png');
853
+    }
854
+	
855
+    /**
856
+     * Returns a copy of the image object
857
+     * 
858
+     * @return \WideImage\Image The copy
859
+     **/
860
+    public function copy()
861
+    {
862
+        $dest = $this->doCreate($this->getWidth(), $this->getHeight());
863
+        $dest->copyTransparencyFrom($this, true);
864
+        $this->copyTo($dest, 0, 0);
865
+        return $dest;
866
+    }
867
+	
868
+    /**
869
+     * Copies this image onto another image
870
+     * 
871
+     * @param \WideImage\Image $dest
872
+     * @param int $left
873
+     * @param int $top
874
+     **/
875
+    public function copyTo($dest, $left = 0, $top = 0)
876
+    {
877
+        if (!imagecopy($dest->getHandle(), $this->handle, $left, $top, 0, 0, $this->getWidth(), $this->getHeight())) {
878
+            throw new GDFunctionResultException("imagecopy() returned false");
879
+        }
880
+    }
881
+	
882
+    /**
883
+     * Returns the canvas object
884
+     * 
885
+     * The Canvas object can be used to draw text and shapes on the image
886
+     * 
887
+     * Examples:
888
+     * <code>
889
+     * $img = WideImage::load('pic.jpg);
890
+     * $canvas = $img->getCanvas();
891
+     * $canvas->useFont('arial.ttf', 15, $img->allocateColor(200, 220, 255));
892
+     * $canvas->writeText(10, 50, "Hello world!");
893
+     * 
894
+     * $canvas->filledRectangle(10, 10, 80, 40, $img->allocateColor(255, 127, 255));
895
+     * $canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0));
896
+     * $img->saveToFile('new.png');
897
+     * </code>
898
+     * 
899
+     * @return \WideImage\Canvas The Canvas object
900
+     **/
901
+    function getCanvas()
902
+    {
903
+        if ($this->canvas == null) {
904
+            $this->canvas = new Canvas($this);
905
+        }
907 906
 		
908
-		return $this->canvas;
909
-	}
910
-	
911
-	/**
912
-	 * Returns true if the image is true-color, false otherwise
913
-	 * 
914
-	 * @return bool
915
-	 **/
916
-	abstract public function isTrueColor();
917
-	
918
-	/**
919
-	 * Returns a true-color copy of the image
920
-	 * 
921
-	 * @return \WideImage\TrueColorImage
922
-	 **/
923
-	abstract public function asTrueColor();
924
-	
925
-	/**
926
-	 * Returns a palette copy (8bit) of the image
927
-	 *
928
-	 * @param int $nColors Number of colors in the resulting image, more than 0, less or equal to 255
929
-	 * @param bool $dither Use dithering or not
930
-	 * @param bool $matchPalette Set to true to use imagecolormatch() to match the resulting palette more closely to the original image 
931
-	 * @return \WideImage\Image
932
-	 **/
933
-	abstract public function asPalette($nColors = 255, $dither = null, $matchPalette = true);
934
-	
935
-	/**
936
-	 * Retrieve an image with selected channels
937
-	 * 
938
-	 * Examples:
939
-	 * <code>
940
-	 * $channels = $img->getChannels('red', 'blue');
941
-	 * $channels = $img->getChannels('alpha', 'green');
942
-	 * $channels = $img->getChannels(array('green', 'blue'));
943
-	 * </code>
944
-	 * 
945
-	 * @return \WideImage\Image
946
-	 **/
947
-	abstract public function getChannels();
948
-	
949
-	/**
950
-	 * Returns an image without an alpha channel
951
-	 * 
952
-	 * @return \WideImage\Image
953
-	 **/
954
-	abstract public function copyNoAlpha();
955
-	
956
-	/**
957
-	 * Returns an array of serializable protected variables. Called automatically upon serialize().
958
-	 * 
959
-	 * @return array
960
-	 */
961
-	public function __sleep()
962
-	{
963
-		$this->sdata = $this->asString('png');
907
+        return $this->canvas;
908
+    }
909
+	
910
+    /**
911
+     * Returns true if the image is true-color, false otherwise
912
+     * 
913
+     * @return bool
914
+     **/
915
+    abstract public function isTrueColor();
916
+	
917
+    /**
918
+     * Returns a true-color copy of the image
919
+     * 
920
+     * @return \WideImage\TrueColorImage
921
+     **/
922
+    abstract public function asTrueColor();
923
+	
924
+    /**
925
+     * Returns a palette copy (8bit) of the image
926
+     *
927
+     * @param int $nColors Number of colors in the resulting image, more than 0, less or equal to 255
928
+     * @param bool $dither Use dithering or not
929
+     * @param bool $matchPalette Set to true to use imagecolormatch() to match the resulting palette more closely to the original image 
930
+     * @return \WideImage\Image
931
+     **/
932
+    abstract public function asPalette($nColors = 255, $dither = null, $matchPalette = true);
933
+	
934
+    /**
935
+     * Retrieve an image with selected channels
936
+     * 
937
+     * Examples:
938
+     * <code>
939
+     * $channels = $img->getChannels('red', 'blue');
940
+     * $channels = $img->getChannels('alpha', 'green');
941
+     * $channels = $img->getChannels(array('green', 'blue'));
942
+     * </code>
943
+     * 
944
+     * @return \WideImage\Image
945
+     **/
946
+    abstract public function getChannels();
947
+	
948
+    /**
949
+     * Returns an image without an alpha channel
950
+     * 
951
+     * @return \WideImage\Image
952
+     **/
953
+    abstract public function copyNoAlpha();
954
+	
955
+    /**
956
+     * Returns an array of serializable protected variables. Called automatically upon serialize().
957
+     * 
958
+     * @return array
959
+     */
960
+    public function __sleep()
961
+    {
962
+        $this->sdata = $this->asString('png');
964 963
 		
965
-		return array('sdata', 'handleReleased');
966
-	}
967
-	
968
-	/**
969
-	 * Restores an image from serialization. Called automatically upon unserialize().
970
-	 */
971
-	public function __wakeup()
972
-	{
973
-		$temp_image = WideImage::loadFromString($this->sdata);
974
-		$temp_image->releaseHandle();
975
-		$this->handle = $temp_image->handle;
976
-		$temp_image = null;
977
-		$this->sdata = null;
978
-	}
964
+        return array('sdata', 'handleReleased');
965
+    }
966
+	
967
+    /**
968
+     * Restores an image from serialization. Called automatically upon unserialize().
969
+     */
970
+    public function __wakeup()
971
+    {
972
+        $temp_image = WideImage::loadFromString($this->sdata);
973
+        $temp_image->releaseHandle();
974
+        $this->handle = $temp_image->handle;
975
+        $temp_image = null;
976
+        $this->sdata = null;
977
+    }
979 978
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		$res = call_user_func_array(array($mapper, 'save'), $args);
154 154
 		
155 155
 		if (!$res) {
156
-			throw new UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while saving to $uri");
156
+			throw new UnknownErrorWhileMappingException(get_class($mapper)." returned an invalid result while saving to $uri");
157 157
 		}
158 158
 	}
159 159
 	
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		$res    = call_user_func_array(array($mapper, 'save'), $args);
177 177
 		
178 178
 		if (!$res) {
179
-			throw new UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while writing the image data");
179
+			throw new UnknownErrorWhileMappingException(get_class($mapper)." returned an invalid result while writing the image data");
180 180
 		}
181 181
 		
182 182
 		return ob_get_clean();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	protected function writeHeader($name, $data)
192 192
 	{
193
-		header($name . ": " . $data);
193
+		header($name.": ".$data);
194 194
 	}
195 195
 	
196 196
 	/**
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/TrueColorImage.php 2 patches
Indentation   +177 added lines, -177 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,7 +17,7 @@  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
-  **/
20
+     **/
21 21
 
22 22
 namespace WideImage;
23 23
 
@@ -30,117 +30,117 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class TrueColorImage extends Image
32 32
 {
33
-	/**
34
-	 * Creates the object
35
-	 *
36
-	 * @param resource $handle
37
-	 */
38
-	public function __construct($handle)
39
-	{
40
-		parent::__construct($handle);
33
+    /**
34
+     * Creates the object
35
+     *
36
+     * @param resource $handle
37
+     */
38
+    public function __construct($handle)
39
+    {
40
+        parent::__construct($handle);
41 41
 		
42
-		$this->alphaBlending(false);
43
-		$this->saveAlpha(true);
44
-	}
42
+        $this->alphaBlending(false);
43
+        $this->saveAlpha(true);
44
+    }
45 45
 	
46
-	/**
47
-	 * Factory method that creates a true-color image object
48
-	 *
49
-	 * @param int $width
50
-	 * @param int $height
51
-	 * @return \WideImage\TrueColorImage
52
-	 */
53
-	public static function create($width, $height)
54
-	{
55
-		if ($width * $height <= 0 || $width < 0) {
56
-			throw new InvalidImageDimensionException("Can't create an image with dimensions [$width, $height].");
57
-		}
46
+    /**
47
+     * Factory method that creates a true-color image object
48
+     *
49
+     * @param int $width
50
+     * @param int $height
51
+     * @return \WideImage\TrueColorImage
52
+     */
53
+    public static function create($width, $height)
54
+    {
55
+        if ($width * $height <= 0 || $width < 0) {
56
+            throw new InvalidImageDimensionException("Can't create an image with dimensions [$width, $height].");
57
+        }
58 58
 		
59
-		return new TrueColorImage(imagecreatetruecolor($width, $height));
60
-	}
59
+        return new TrueColorImage(imagecreatetruecolor($width, $height));
60
+    }
61 61
 	
62
-	public function doCreate($width, $height)
63
-	{
64
-		return static::create($width, $height);
65
-	}
62
+    public function doCreate($width, $height)
63
+    {
64
+        return static::create($width, $height);
65
+    }
66 66
 	
67
-	public function isTrueColor()
68
-	{
69
-		return true;
70
-	}
67
+    public function isTrueColor()
68
+    {
69
+        return true;
70
+    }
71 71
 	
72
-	/**
73
-	 * Sets alpha blending mode via imagealphablending()
74
-	 *
75
-	 * @param bool $mode
76
-	 * @return bool
77
-	 */
78
-	public function alphaBlending($mode)
79
-	{
80
-		return imagealphablending($this->handle, $mode);
81
-	}
72
+    /**
73
+     * Sets alpha blending mode via imagealphablending()
74
+     *
75
+     * @param bool $mode
76
+     * @return bool
77
+     */
78
+    public function alphaBlending($mode)
79
+    {
80
+        return imagealphablending($this->handle, $mode);
81
+    }
82 82
 	
83
-	/**
84
-	 * Toggle if alpha channel should be saved with the image via imagesavealpha()
85
-	 *
86
-	 * @param bool $on
87
-	 * @return bool
88
-	 */
89
-	public function saveAlpha($on)
90
-	{
91
-		return imagesavealpha($this->handle, $on);
92
-	}
83
+    /**
84
+     * Toggle if alpha channel should be saved with the image via imagesavealpha()
85
+     *
86
+     * @param bool $on
87
+     * @return bool
88
+     */
89
+    public function saveAlpha($on)
90
+    {
91
+        return imagesavealpha($this->handle, $on);
92
+    }
93 93
 	
94
-	/**
95
-	 * Allocates a color and returns its index
96
-	 * 
97
-	 * This method accepts either each component as an integer value,
98
-	 * or an associative array that holds the color's components in keys
99
-	 * 'red', 'green', 'blue', 'alpha'.
100
-	 *
101
-	 * @param mixed $R
102
-	 * @param int $G
103
-	 * @param int $B
104
-	 * @param int $A
105
-	 * @return int
106
-	 */
107
-	public function allocateColorAlpha($R, $G = null, $B = null, $A = null)
108
-	{
109
-		if (is_array($R)) {
110
-			return imageColorAllocateAlpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
111
-		}
94
+    /**
95
+     * Allocates a color and returns its index
96
+     * 
97
+     * This method accepts either each component as an integer value,
98
+     * or an associative array that holds the color's components in keys
99
+     * 'red', 'green', 'blue', 'alpha'.
100
+     *
101
+     * @param mixed $R
102
+     * @param int $G
103
+     * @param int $B
104
+     * @param int $A
105
+     * @return int
106
+     */
107
+    public function allocateColorAlpha($R, $G = null, $B = null, $A = null)
108
+    {
109
+        if (is_array($R)) {
110
+            return imageColorAllocateAlpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
111
+        }
112 112
 		
113
-		return imageColorAllocateAlpha($this->handle, $R, $G, $B, $A);
114
-	}
113
+        return imageColorAllocateAlpha($this->handle, $R, $G, $B, $A);
114
+    }
115 115
 	
116
-	/**
117
-	 * @see \WideImage\Image#asPalette($nColors, $dither, $matchPalette)
118
-	 */
119
-	public function asPalette($nColors = 255, $dither = null, $matchPalette = true)
120
-	{
121
-		$nColors = intval($nColors);
116
+    /**
117
+     * @see \WideImage\Image#asPalette($nColors, $dither, $matchPalette)
118
+     */
119
+    public function asPalette($nColors = 255, $dither = null, $matchPalette = true)
120
+    {
121
+        $nColors = intval($nColors);
122 122
 		
123
-		if ($nColors < 1) {
124
-			$nColors = 1;
125
-		} elseif ($nColors > 255) {
126
-			$nColors = 255;
127
-		}
123
+        if ($nColors < 1) {
124
+            $nColors = 1;
125
+        } elseif ($nColors > 255) {
126
+            $nColors = 255;
127
+        }
128 128
 		
129
-		if ($dither === null) {
130
-			$dither = $this->isTransparent();
131
-		}
129
+        if ($dither === null) {
130
+            $dither = $this->isTransparent();
131
+        }
132 132
 		
133
-		$temp = $this->copy();
133
+        $temp = $this->copy();
134 134
 		
135
-		imagetruecolortopalette($temp->handle, $dither, $nColors);
135
+        imagetruecolortopalette($temp->handle, $dither, $nColors);
136 136
 		
137
-		if ($matchPalette == true && function_exists('imagecolormatch')) {
138
-			imagecolormatch($this->handle, $temp->handle);
139
-		}
137
+        if ($matchPalette == true && function_exists('imagecolormatch')) {
138
+            imagecolormatch($this->handle, $temp->handle);
139
+        }
140 140
 		
141
-		// The code below isn't working properly; it corrupts transparency on some palette->tc->palette conversions.
142
-		// Why is this code here?
143
-		/*
141
+        // The code below isn't working properly; it corrupts transparency on some palette->tc->palette conversions.
142
+        // Why is this code here?
143
+        /*
144 144
 		if ($this->isTransparent())
145 145
 		{
146 146
 			$trgb = $this->getTransparentColorRGB();
@@ -149,97 +149,97 @@  discard block
 block discarded – undo
149 149
 		}
150 150
 		/**/
151 151
 		
152
-		$temp->releaseHandle();
152
+        $temp->releaseHandle();
153 153
 		
154
-		return new PaletteImage($temp->handle);
155
-	}
154
+        return new PaletteImage($temp->handle);
155
+    }
156 156
 	
157
-	/**
158
-	 * Returns the index of the color that best match the given color components
159
-	 *
160
-	 * This method accepts either each component as an integer value,
161
-	 * or an associative array that holds the color's components in keys
162
-	 * 'red', 'green', 'blue', 'alpha'.
163
-	 *
164
-	 * @param mixed $R Red component value or an associative array
165
-	 * @param int $G Green component
166
-	 * @param int $B Blue component
167
-	 * @param int $A Alpha component
168
-	 * @return int The color index
169
-	 */
170
-	public function getClosestColorAlpha($R, $G = null, $B = null, $A = null)
171
-	{
172
-		if (is_array($R)) {
173
-			return imagecolorclosestalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
174
-		}
157
+    /**
158
+     * Returns the index of the color that best match the given color components
159
+     *
160
+     * This method accepts either each component as an integer value,
161
+     * or an associative array that holds the color's components in keys
162
+     * 'red', 'green', 'blue', 'alpha'.
163
+     *
164
+     * @param mixed $R Red component value or an associative array
165
+     * @param int $G Green component
166
+     * @param int $B Blue component
167
+     * @param int $A Alpha component
168
+     * @return int The color index
169
+     */
170
+    public function getClosestColorAlpha($R, $G = null, $B = null, $A = null)
171
+    {
172
+        if (is_array($R)) {
173
+            return imagecolorclosestalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
174
+        }
175 175
 		
176
-		return imagecolorclosestalpha($this->handle, $R, $G, $B, $A);
177
-	}
176
+        return imagecolorclosestalpha($this->handle, $R, $G, $B, $A);
177
+    }
178 178
 	
179
-	/**
180
-	 * Returns the index of the color that exactly match the given color components
181
-	 *
182
-	 * This method accepts either each component as an integer value,
183
-	 * or an associative array that holds the color's components in keys
184
-	 * 'red', 'green', 'blue', 'alpha'.
185
-	 *
186
-	 * @param mixed $R Red component value or an associative array
187
-	 * @param int $G Green component
188
-	 * @param int $B Blue component
189
-	 * @param int $A Alpha component
190
-	 * @return int The color index
191
-	 */
192
-	public function getExactColorAlpha($R, $G = null, $B = null, $A = null)
193
-	{
194
-		if (is_array($R)) {
195
-			return imagecolorexactalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
196
-		}
179
+    /**
180
+     * Returns the index of the color that exactly match the given color components
181
+     *
182
+     * This method accepts either each component as an integer value,
183
+     * or an associative array that holds the color's components in keys
184
+     * 'red', 'green', 'blue', 'alpha'.
185
+     *
186
+     * @param mixed $R Red component value or an associative array
187
+     * @param int $G Green component
188
+     * @param int $B Blue component
189
+     * @param int $A Alpha component
190
+     * @return int The color index
191
+     */
192
+    public function getExactColorAlpha($R, $G = null, $B = null, $A = null)
193
+    {
194
+        if (is_array($R)) {
195
+            return imagecolorexactalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
196
+        }
197 197
 		
198
-		return imagecolorexactalpha($this->handle, $R, $G, $B, $A);
199
-	}
198
+        return imagecolorexactalpha($this->handle, $R, $G, $B, $A);
199
+    }
200 200
 	
201
-	/**
202
-	 * @see \WideImage\Image#getChannels()
203
-	 */
204
-	public function getChannels()
205
-	{
206
-		$args = func_get_args();
201
+    /**
202
+     * @see \WideImage\Image#getChannels()
203
+     */
204
+    public function getChannels()
205
+    {
206
+        $args = func_get_args();
207 207
 		
208
-		if (count($args) == 1 && is_array($args[0])) {
209
-			$args = $args[0];
210
-		}
208
+        if (count($args) == 1 && is_array($args[0])) {
209
+            $args = $args[0];
210
+        }
211 211
 		
212
-		return OperationFactory::get('CopyChannelsTrueColor')->execute($this, $args);
213
-	}
212
+        return OperationFactory::get('CopyChannelsTrueColor')->execute($this, $args);
213
+    }
214 214
 	
215
-	/**
216
-	 * (non-PHPdoc)
217
-	 * @see \WideImage\Image#copyNoAlpha()
218
-	 */
219
-	public function copyNoAlpha()
220
-	{
221
-		$prev   = $this->saveAlpha(false);
222
-		$result = WideImage::loadFromString($this->asString('png'));
223
-		$this->saveAlpha($prev);
224
-		//$result->releaseHandle();
225
-		return $result;
226
-	}
215
+    /**
216
+     * (non-PHPdoc)
217
+     * @see \WideImage\Image#copyNoAlpha()
218
+     */
219
+    public function copyNoAlpha()
220
+    {
221
+        $prev   = $this->saveAlpha(false);
222
+        $result = WideImage::loadFromString($this->asString('png'));
223
+        $this->saveAlpha($prev);
224
+        //$result->releaseHandle();
225
+        return $result;
226
+    }
227 227
 	
228
-	/**
229
-	 * (non-PHPdoc)
230
-	 * @see \WideImage\Image#asTrueColor()
231
-         * @return TrueColorImage
232
-	 */
233
-	public function asTrueColor()
234
-	{
235
-		return $this->copy();
236
-	}
228
+    /**
229
+     * (non-PHPdoc)
230
+     * @see \WideImage\Image#asTrueColor()
231
+     * @return TrueColorImage
232
+     */
233
+    public function asTrueColor()
234
+    {
235
+        return $this->copy();
236
+    }
237 237
         
238
-	/**
239
-	 * Calls imageinterlace() using the current handler
240
-	 * @see \WideImage\Image#asTrueColor()
241
-         * @return TrueColorImage A copy of the image, with imageinterlace() applied
242
-	 */
238
+    /**
239
+     * Calls imageinterlace() using the current handler
240
+     * @see \WideImage\Image#asTrueColor()
241
+     * @return TrueColorImage A copy of the image, with imageinterlace() applied
242
+     */
243 243
         public function asProgressive()
244 244
         {
245 245
             $dest = $this->asTrueColor();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
          * @return TrueColorImage A new, resized image
268 268
          */
269 269
         public function resizeInsideRect($width, $height, $fit = 'inside', $scale = 'down', $alignLeft = 'center', 
270
-                $alignTop = 'center', $mergeOpacity = 100,  $fillColor = null)
270
+                $alignTop = 'center', $mergeOpacity = 100, $fillColor = null)
271 271
         {
272 272
 
273 273
             if ($fillColor) {
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/Coordinate.php 2 patches
Indentation   +147 added lines, -148 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 Internals
22
-  **/
20
+     * @package Internals
21
+     **/
23 22
 
24 23
 namespace WideImage;
25 24
 
@@ -33,166 +32,166 @@  discard block
 block discarded – undo
33 32
  **/
34 33
 class Coordinate
35 34
 {
36
-	protected static $coord_align   = array('left', 'center', 'right', 'top', 'middle', 'bottom');
37
-	protected static $coord_numeric = array('[0-9]+', '[0-9]+\.[0-9]+', '[0-9]+%', '[0-9]+\.[0-9]+%');
35
+    protected static $coord_align   = array('left', 'center', 'right', 'top', 'middle', 'bottom');
36
+    protected static $coord_numeric = array('[0-9]+', '[0-9]+\.[0-9]+', '[0-9]+%', '[0-9]+\.[0-9]+%');
38 37
 	
39
-	/**
40
-	 * Parses a numeric or string representation of a corrdinate into a structure
41
-	 * 
42
-	 * @param string $coord Smart coordinate
43
-	 * @return array Parsed smart coordinate
44
-	 */
45
-	public static function parse($c)
46
-	{
47
-		$tokens    = array();
48
-		$operators = array('+', '-');
38
+    /**
39
+     * Parses a numeric or string representation of a corrdinate into a structure
40
+     * 
41
+     * @param string $coord Smart coordinate
42
+     * @return array Parsed smart coordinate
43
+     */
44
+    public static function parse($c)
45
+    {
46
+        $tokens    = array();
47
+        $operators = array('+', '-');
49 48
 		
50
-		$flush_operand    = false;
51
-		$flush_operator   = false;
52
-		$current_operand  = '';
53
-		$current_operator = '';
54
-		$coordinate       = strval($c);
55
-		$expr_len         = strlen($coordinate);
49
+        $flush_operand    = false;
50
+        $flush_operator   = false;
51
+        $current_operand  = '';
52
+        $current_operator = '';
53
+        $coordinate       = strval($c);
54
+        $expr_len         = strlen($coordinate);
56 55
 		
57
-		for ($i = 0; $i < $expr_len; $i++) {
58
-			$char = $coordinate[$i];
56
+        for ($i = 0; $i < $expr_len; $i++) {
57
+            $char = $coordinate[$i];
59 58
 			
60
-			if (in_array($char, $operators)) {
61
-				$flush_operand    = true;
62
-				$flush_operator   = true;
63
-				$current_operator = $char;
64
-			} else {
65
-				$current_operand .= $char;
66
-				if ($i == $expr_len - 1) {
67
-					$flush_operand = true;
68
-				}
69
-			}
59
+            if (in_array($char, $operators)) {
60
+                $flush_operand    = true;
61
+                $flush_operator   = true;
62
+                $current_operator = $char;
63
+            } else {
64
+                $current_operand .= $char;
65
+                if ($i == $expr_len - 1) {
66
+                    $flush_operand = true;
67
+                }
68
+            }
70 69
 			
71
-			if ($flush_operand) {
72
-				if (trim($current_operand) != '') {
73
-					$tokens[] = array('type' => 'operand', 'value' => trim($current_operand));
74
-				}
70
+            if ($flush_operand) {
71
+                if (trim($current_operand) != '') {
72
+                    $tokens[] = array('type' => 'operand', 'value' => trim($current_operand));
73
+                }
75 74
 				
76
-				$current_operand = '';
77
-				$flush_operand   = false;
78
-			}
75
+                $current_operand = '';
76
+                $flush_operand   = false;
77
+            }
79 78
 			
80
-			if ($flush_operator) {
81
-				$tokens[]       = array('type' => 'operator', 'value' => $char);
82
-				$flush_operator = false;
83
-			}
84
-		}
79
+            if ($flush_operator) {
80
+                $tokens[]       = array('type' => 'operator', 'value' => $char);
81
+                $flush_operator = false;
82
+            }
83
+        }
85 84
 		
86
-		return $tokens;
87
-	}
85
+        return $tokens;
86
+    }
88 87
 	
89
-	/**
90
-	 * Evaluates the $coord relatively to $dim
91
-	 * 
92
-	 * @param string $coord A numeric value or percent string
93
-	 * @param int $dim Dimension
94
-	 * @param int $sec_dim Secondary dimension (for align)
95
-	 * @return int Calculated value
96
-	 */
97
-	public static function evaluate($coord, $dim, $sec_dim = null)
98
-	{
99
-		$comp_regex = implode('|', self::$coord_align) . '|' . implode('|', self::$coord_numeric);
88
+    /**
89
+     * Evaluates the $coord relatively to $dim
90
+     * 
91
+     * @param string $coord A numeric value or percent string
92
+     * @param int $dim Dimension
93
+     * @param int $sec_dim Secondary dimension (for align)
94
+     * @return int Calculated value
95
+     */
96
+    public static function evaluate($coord, $dim, $sec_dim = null)
97
+    {
98
+        $comp_regex = implode('|', self::$coord_align) . '|' . implode('|', self::$coord_numeric);
100 99
 		
101
-		if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) {
102
-			$sign = intval($matches[1] . "1");
103
-			$val  = $matches[2];
100
+        if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) {
101
+            $sign = intval($matches[1] . "1");
102
+            $val  = $matches[2];
104 103
 			
105
-			if (in_array($val, self::$coord_align)) {
106
-				if ($sec_dim === null) {
107
-					switch ($val) {
108
-						case 'left':
109
-						case 'top':
110
-							return 0;
111
-							break;
112
-						case 'center':
113
-						case 'middle':
114
-							return $sign * intval($dim / 2);
115
-							break;
116
-						case 'right':
117
-						case 'bottom':
118
-							return $sign * $dim;
119
-							break;
120
-						default:
121
-							return null;
122
-					}
123
-				} else {
124
-					switch ($val) {
125
-						case 'left':
126
-						case 'top':
127
-							return 0;
128
-							break;
129
-						case 'center':
130
-						case 'middle':
131
-							return $sign * intval($dim / 2 - $sec_dim / 2);
132
-							break;
133
-						case 'right':
134
-						case 'bottom':
135
-							return $sign * ($dim - $sec_dim);
136
-							break;
137
-						default:
138
-							return null;
139
-					}
140
-				}
141
-			} elseif (substr($val, -1) === '%') {
142
-				return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
143
-			} else {
144
-				return $sign * intval(round($val));
145
-			}
146
-		}
147
-	}
104
+            if (in_array($val, self::$coord_align)) {
105
+                if ($sec_dim === null) {
106
+                    switch ($val) {
107
+                        case 'left':
108
+                        case 'top':
109
+                            return 0;
110
+                            break;
111
+                        case 'center':
112
+                        case 'middle':
113
+                            return $sign * intval($dim / 2);
114
+                            break;
115
+                        case 'right':
116
+                        case 'bottom':
117
+                            return $sign * $dim;
118
+                            break;
119
+                        default:
120
+                            return null;
121
+                    }
122
+                } else {
123
+                    switch ($val) {
124
+                        case 'left':
125
+                        case 'top':
126
+                            return 0;
127
+                            break;
128
+                        case 'center':
129
+                        case 'middle':
130
+                            return $sign * intval($dim / 2 - $sec_dim / 2);
131
+                            break;
132
+                        case 'right':
133
+                        case 'bottom':
134
+                            return $sign * ($dim - $sec_dim);
135
+                            break;
136
+                        default:
137
+                            return null;
138
+                    }
139
+                }
140
+            } elseif (substr($val, -1) === '%') {
141
+                return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
142
+            } else {
143
+                return $sign * intval(round($val));
144
+            }
145
+        }
146
+    }
148 147
 	
149
-	/**
150
-	 * Calculates and fixes a smart coordinate into a numeric value
151
-	 * 
152
-	 * @param mixed $value Smart coordinate, relative to $dim
153
-	 * @param int $dim Coordinate to which $value is relative
154
-	 * @param int $sec_dim Secondary dimension (for align)
155
-	 * @return int Calculated value
156
-	 */
157
-	public static function fix($value, $dim, $sec_dim = null)
158
-	{
159
-		$coord_tokens = self::parse($value);
148
+    /**
149
+     * Calculates and fixes a smart coordinate into a numeric value
150
+     * 
151
+     * @param mixed $value Smart coordinate, relative to $dim
152
+     * @param int $dim Coordinate to which $value is relative
153
+     * @param int $sec_dim Secondary dimension (for align)
154
+     * @return int Calculated value
155
+     */
156
+    public static function fix($value, $dim, $sec_dim = null)
157
+    {
158
+        $coord_tokens = self::parse($value);
160 159
 		
161
-		if (count($coord_tokens) == 0 || $coord_tokens[count($coord_tokens) - 1]['type'] != 'operand') {
162
-			throw new InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
163
-		}
160
+        if (count($coord_tokens) == 0 || $coord_tokens[count($coord_tokens) - 1]['type'] != 'operand') {
161
+            throw new InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
162
+        }
164 163
 		
165
-		$value     = 0;
166
-		$operation = 1;
164
+        $value     = 0;
165
+        $operation = 1;
167 166
 		
168
-		foreach ($coord_tokens as $token) {
169
-			if ($token['type'] == 'operand') {
170
-				$operand_value = self::evaluate($token['value'], $dim, $sec_dim);
167
+        foreach ($coord_tokens as $token) {
168
+            if ($token['type'] == 'operand') {
169
+                $operand_value = self::evaluate($token['value'], $dim, $sec_dim);
171 170
 				
172
-				if ($operation == 1) {
173
-					$value = $value + $operand_value;
174
-				} elseif ($operation == -1) {
175
-					$value = $value - $operand_value;
176
-				} else {
177
-					throw new InvalidCoordinateException("Invalid coordinate syntax.");
178
-				}
171
+                if ($operation == 1) {
172
+                    $value = $value + $operand_value;
173
+                } elseif ($operation == -1) {
174
+                    $value = $value - $operand_value;
175
+                } else {
176
+                    throw new InvalidCoordinateException("Invalid coordinate syntax.");
177
+                }
179 178
 				
180
-				$operation = 0;
181
-			} elseif ($token['type'] == 'operator') {
182
-				if ($token['value'] == '-') {
183
-					if ($operation == 0) {
184
-						$operation = -1;
185
-					} else {
186
-						$operation = $operation * -1;
187
-					}
188
-				} elseif ($token['value'] == '+') {
189
-					if ($operation == 0) {
190
-						$operation = '1';
191
-					}
192
-				}
193
-			}
194
-		}
179
+                $operation = 0;
180
+            } elseif ($token['type'] == 'operator') {
181
+                if ($token['value'] == '-') {
182
+                    if ($operation == 0) {
183
+                        $operation = -1;
184
+                    } else {
185
+                        $operation = $operation * -1;
186
+                    }
187
+                } elseif ($token['value'] == '+') {
188
+                    if ($operation == 0) {
189
+                        $operation = '1';
190
+                    }
191
+                }
192
+            }
193
+        }
195 194
 		
196
-		return $value;
197
-	}
195
+        return $value;
196
+    }
198 197
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,10 +96,10 @@
 block discarded – undo
96 96
 	 */
97 97
 	public static function evaluate($coord, $dim, $sec_dim = null)
98 98
 	{
99
-		$comp_regex = implode('|', self::$coord_align) . '|' . implode('|', self::$coord_numeric);
99
+		$comp_regex = implode('|', self::$coord_align).'|'.implode('|', self::$coord_numeric);
100 100
 		
101 101
 		if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) {
102
-			$sign = intval($matches[1] . "1");
102
+			$sign = intval($matches[1]."1");
103 103
 			$val  = $matches[2];
104 104
 			
105 105
 			if (in_array($val, self::$coord_align)) {
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/WideImage.php 2 patches
Indentation   +285 added lines, -286 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@  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 21
  * @package WideImage
23 22
 **/
24 23
 	
@@ -37,336 +36,336 @@  discard block
 block discarded – undo
37 36
  */
38 37
 class WideImage
39 38
 {
40
-	const SIDE_TOP_LEFT = 1;
41
-	const SIDE_TOP = 2;
42
-	const SIDE_TOP_RIGHT = 4;
43
-	const SIDE_RIGHT = 8;
44
-	const SIDE_BOTTOM_RIGHT = 16;
45
-	const SIDE_BOTTOM = 32;
46
-	const SIDE_BOTTOM_LEFT = 64;
47
-	const SIDE_LEFT = 128;
48
-	const SIDE_ALL = 255;
39
+    const SIDE_TOP_LEFT = 1;
40
+    const SIDE_TOP = 2;
41
+    const SIDE_TOP_RIGHT = 4;
42
+    const SIDE_RIGHT = 8;
43
+    const SIDE_BOTTOM_RIGHT = 16;
44
+    const SIDE_BOTTOM = 32;
45
+    const SIDE_BOTTOM_LEFT = 64;
46
+    const SIDE_LEFT = 128;
47
+    const SIDE_ALL = 255;
49 48
 	
50
-	/**
51
-	 * @var string Path to the library base directory
52
-	 */
53
-	protected static $path = null;
49
+    /**
50
+     * @var string Path to the library base directory
51
+     */
52
+    protected static $path = null;
54 53
 	
55
-	/**
56
-	 * Returns the library version
57
-	 * @return string The library version
58
-	 */
59
-	public static function version()
60
-	{
61
-		return '##DEV##';
62
-	}
54
+    /**
55
+     * Returns the library version
56
+     * @return string The library version
57
+     */
58
+    public static function version()
59
+    {
60
+        return '##DEV##';
61
+    }
63 62
 	
64
-	/**
65
-	 * Returns the path to the library
66
-	 * @return string
67
-	 */
68
-	public static function path()
69
-	{
70
-		if (static::$path === null) {
71
-			static::$path = __DIR__ . DIRECTORY_SEPARATOR;
72
-		}
63
+    /**
64
+     * Returns the path to the library
65
+     * @return string
66
+     */
67
+    public static function path()
68
+    {
69
+        if (static::$path === null) {
70
+            static::$path = __DIR__ . DIRECTORY_SEPARATOR;
71
+        }
73 72
 		
74
-		return static::$path;
75
-	}
73
+        return static::$path;
74
+    }
76 75
 	
77
-	/**
78
-	 * Checks whether the gd library is loaded, and throws an exception otherwise
79
-	 */
80
-	public static function checkGD()
81
-	{
82
-		if (!extension_loaded('gd')) {
83
-			throw new Exception("WideImage requires the GD extension, but it's apparently not loaded.");
84
-		}
85
-	}
76
+    /**
77
+     * Checks whether the gd library is loaded, and throws an exception otherwise
78
+     */
79
+    public static function checkGD()
80
+    {
81
+        if (!extension_loaded('gd')) {
82
+            throw new Exception("WideImage requires the GD extension, but it's apparently not loaded.");
83
+        }
84
+    }
86 85
 
87
-	/**
88
-	 * Registers a custom mapper for image loading and saving
89
-	 * 
90
-	 * Example:
91
-	 * <code>
92
-	 * 	\WideImage\WideImage::registerCustomMapper('\\WideImage\\Mapper\\TGA', 'image/tga', 'tga');
93
-	 * </code>
94
-	 * 
95
-	 * @param string $mapper_class_name
96
-	 * @param string $mime_type
97
-	 * @param string $extension
98
-	 */
99
-	public static function registerCustomMapper($mapper_class_name, $mime_type, $extension)
100
-	{
101
-		MapperFactory::registerMapper($mapper_class_name, $mime_type, strtoupper($extension));
102
-	}
86
+    /**
87
+     * Registers a custom mapper for image loading and saving
88
+     * 
89
+     * Example:
90
+     * <code>
91
+     * 	\WideImage\WideImage::registerCustomMapper('\\WideImage\\Mapper\\TGA', 'image/tga', 'tga');
92
+     * </code>
93
+     * 
94
+     * @param string $mapper_class_name
95
+     * @param string $mime_type
96
+     * @param string $extension
97
+     */
98
+    public static function registerCustomMapper($mapper_class_name, $mime_type, $extension)
99
+    {
100
+        MapperFactory::registerMapper($mapper_class_name, $mime_type, strtoupper($extension));
101
+    }
103 102
 	
104
-	/**
105
-	 * Loads an image from a file, URL, HTML input file field, binary string, or a valid image handle.
106
-	 * The image format is auto-detected. 
107
-	 * 
108
-	 * Currently supported formats: PNG, GIF, JPG, BMP, TGA, GD, GD2.
109
-	 * 
110
-	 * This function analyzes the input and decides whether to use WideImage::loadFromHandle(),
111
-	 * WideImage::loadFromFile(), WideImage::loadFromUpload() or WideImage::loadFromString(),
112
-	 * all of which you can also call directly to spare WideImage some guessing.
113
-	 * 
114
-	 * Arrays are supported for upload fields; it returns an array of loaded images. 
115
-	 * To load only a single image from an array field, use WideImage::loadFromUpload('img', $i), 
116
-	 * where $i is the index of the image you want to load.
117
-	 * 
118
-	 * <code>
119
-	 * $img = WideImage::load('http://url/image.png'); // image URL
120
-	 * $img = WideImage::load('/path/to/image.png'); // local file path
121
-	 * $img = WideImage::load('img'); // upload field name
122
-	 * $img = WideImage::load(imagecreatetruecolor(10, 10)); // a GD resource
123
-	 * $img = WideImage::load($image_data); // binary string containing image data
124
-	 * </code>
125
-	 * 
126
-	 * @param mixed $source File name, url, HTML file input field name, binary string, or a GD image resource
127
-	 * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
128
-	 */
129
-	public static function load($source)
130
-	{
131
-		$predictedSourceType = '';
103
+    /**
104
+     * Loads an image from a file, URL, HTML input file field, binary string, or a valid image handle.
105
+     * The image format is auto-detected. 
106
+     * 
107
+     * Currently supported formats: PNG, GIF, JPG, BMP, TGA, GD, GD2.
108
+     * 
109
+     * This function analyzes the input and decides whether to use WideImage::loadFromHandle(),
110
+     * WideImage::loadFromFile(), WideImage::loadFromUpload() or WideImage::loadFromString(),
111
+     * all of which you can also call directly to spare WideImage some guessing.
112
+     * 
113
+     * Arrays are supported for upload fields; it returns an array of loaded images. 
114
+     * To load only a single image from an array field, use WideImage::loadFromUpload('img', $i), 
115
+     * where $i is the index of the image you want to load.
116
+     * 
117
+     * <code>
118
+     * $img = WideImage::load('http://url/image.png'); // image URL
119
+     * $img = WideImage::load('/path/to/image.png'); // local file path
120
+     * $img = WideImage::load('img'); // upload field name
121
+     * $img = WideImage::load(imagecreatetruecolor(10, 10)); // a GD resource
122
+     * $img = WideImage::load($image_data); // binary string containing image data
123
+     * </code>
124
+     * 
125
+     * @param mixed $source File name, url, HTML file input field name, binary string, or a GD image resource
126
+     * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
127
+     */
128
+    public static function load($source)
129
+    {
130
+        $predictedSourceType = '';
132 131
 		
133
-		if ($source == '') {
134
-			$predictedSourceType = 'String';
135
-		}
132
+        if ($source == '') {
133
+            $predictedSourceType = 'String';
134
+        }
136 135
 		
137
-		// Creating image via a valid resource
138
-		if (!$predictedSourceType && static::isValidImageHandle($source)) {
139
-			$predictedSourceType = 'Handle';
140
-		}
136
+        // Creating image via a valid resource
137
+        if (!$predictedSourceType && static::isValidImageHandle($source)) {
138
+            $predictedSourceType = 'Handle';
139
+        }
141 140
 		
142
-		// Check for binary string
143
-		if (!$predictedSourceType) {
144
-			// search first $binLength bytes (at a maximum) for ord<32 characters (binary image data)
145
-			$binLength    = 64;
146
-			$sourceLength = strlen($source);
147
-			$maxlen       = ($sourceLength > $binLength) ? $binLength : $sourceLength;
141
+        // Check for binary string
142
+        if (!$predictedSourceType) {
143
+            // search first $binLength bytes (at a maximum) for ord<32 characters (binary image data)
144
+            $binLength    = 64;
145
+            $sourceLength = strlen($source);
146
+            $maxlen       = ($sourceLength > $binLength) ? $binLength : $sourceLength;
148 147
 			
149
-			for ($i = 0; $i < $maxlen; $i++) {
150
-				if (ord($source[$i]) < 32) {
151
-					$predictedSourceType = 'String';
152
-					break;
153
-				}
154
-			}
155
-		}
148
+            for ($i = 0; $i < $maxlen; $i++) {
149
+                if (ord($source[$i]) < 32) {
150
+                    $predictedSourceType = 'String';
151
+                    break;
152
+                }
153
+            }
154
+        }
156 155
 		
157
-		// Uploaded image (array uploads not supported)
158
-		if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name'])) {
159
-			$predictedSourceType = 'Upload';
160
-		}
156
+        // Uploaded image (array uploads not supported)
157
+        if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name'])) {
158
+            $predictedSourceType = 'Upload';
159
+        }
161 160
 		
162
-		// Otherwise, must be a file or an URL
163
-		if (!$predictedSourceType) {
164
-			$predictedSourceType = 'File';
165
-		}
161
+        // Otherwise, must be a file or an URL
162
+        if (!$predictedSourceType) {
163
+            $predictedSourceType = 'File';
164
+        }
166 165
 		
167
-		return call_user_func(array(__CLASS__, 'loadFrom' . $predictedSourceType), $source);
168
-	}
166
+        return call_user_func(array(__CLASS__, 'loadFrom' . $predictedSourceType), $source);
167
+    }
169 168
 
170
-	/**
171
-	 * Create and load an image from a file or URL. The image format is auto-detected.
172
-	 * 
173
-	 * @param string $uri File or url
174
-	 * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
175
-	 */
176
-	public static function loadFromFile($uri)
177
-	{
178
-		$data   = file_get_contents($uri);
179
-		$handle = @imagecreatefromstring($data);
169
+    /**
170
+     * Create and load an image from a file or URL. The image format is auto-detected.
171
+     * 
172
+     * @param string $uri File or url
173
+     * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
174
+     */
175
+    public static function loadFromFile($uri)
176
+    {
177
+        $data   = file_get_contents($uri);
178
+        $handle = @imagecreatefromstring($data);
180 179
 		
181
-		if (!static::isValidImageHandle($handle)) {
182
-			try {
183
-				// try to find a mapper first
184
-				$mapper = MapperFactory::selectMapper($uri);
180
+        if (!static::isValidImageHandle($handle)) {
181
+            try {
182
+                // try to find a mapper first
183
+                $mapper = MapperFactory::selectMapper($uri);
185 184
 				
186
-				if ($mapper) {
187
-					$handle = $mapper->load($uri);
188
-				}
189
-			} catch (UnsupportedFormatException $e) {
190
-				// mapper not found
191
-			}
185
+                if ($mapper) {
186
+                    $handle = $mapper->load($uri);
187
+                }
188
+            } catch (UnsupportedFormatException $e) {
189
+                // mapper not found
190
+            }
192 191
 			
193
-			// try all custom mappers
194
-			if (!static::isValidImageHandle($handle)) {
195
-				$custom_mappers = MapperFactory::getCustomMappers();
192
+            // try all custom mappers
193
+            if (!static::isValidImageHandle($handle)) {
194
+                $custom_mappers = MapperFactory::getCustomMappers();
196 195
 				
197
-				foreach ($custom_mappers as $mime_type => $mapper_class) {
198
-					$mapper = MapperFactory::selectMapper(null, $mime_type);
199
-					$handle = $mapper->loadFromString($data);
196
+                foreach ($custom_mappers as $mime_type => $mapper_class) {
197
+                    $mapper = MapperFactory::selectMapper(null, $mime_type);
198
+                    $handle = $mapper->loadFromString($data);
200 199
 					
201
-					if (static::isValidImageHandle($handle)) {
202
-						break;
203
-					}
204
-				}
205
-			}
206
-		}
200
+                    if (static::isValidImageHandle($handle)) {
201
+                        break;
202
+                    }
203
+                }
204
+            }
205
+        }
207 206
 		
208
-		if (!static::isValidImageHandle($handle)) {
209
-			throw new InvalidImageSourceException("File '{$uri}' appears to be an invalid image source.");
210
-		}
207
+        if (!static::isValidImageHandle($handle)) {
208
+            throw new InvalidImageSourceException("File '{$uri}' appears to be an invalid image source.");
209
+        }
211 210
 		
212
-		return static::loadFromHandle($handle);
213
-	}
211
+        return static::loadFromHandle($handle);
212
+    }
214 213
 
215
-	/**
216
-	 * Create and load an image from a string. Format is auto-detected.
217
-	 * 
218
-	 * @param string $string Binary data, i.e. from BLOB field in the database
219
-	 * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
220
-	 */
221
-	public static function loadFromString($string)
222
-	{
223
-		if (strlen($string) < 128) {
224
-			throw new InvalidImageSourceException("String doesn't contain image data.");
225
-		}
214
+    /**
215
+     * Create and load an image from a string. Format is auto-detected.
216
+     * 
217
+     * @param string $string Binary data, i.e. from BLOB field in the database
218
+     * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
219
+     */
220
+    public static function loadFromString($string)
221
+    {
222
+        if (strlen($string) < 128) {
223
+            throw new InvalidImageSourceException("String doesn't contain image data.");
224
+        }
226 225
 		
227
-		$handle = @imagecreatefromstring($string);
226
+        $handle = @imagecreatefromstring($string);
228 227
 		
229
-		if (!static::isValidImageHandle($handle)) {
230
-			$custom_mappers = MapperFactory::getCustomMappers();
228
+        if (!static::isValidImageHandle($handle)) {
229
+            $custom_mappers = MapperFactory::getCustomMappers();
231 230
 			
232
-			foreach ($custom_mappers as $mime_type => $mapper_class) {
233
-				$mapper = MapperFactory::selectMapper(null, $mime_type);
234
-				$handle = $mapper->loadFromString($string);
231
+            foreach ($custom_mappers as $mime_type => $mapper_class) {
232
+                $mapper = MapperFactory::selectMapper(null, $mime_type);
233
+                $handle = $mapper->loadFromString($string);
235 234
 				
236
-				if (static::isValidImageHandle($handle)) {
237
-					break;
238
-				}
239
-			}
240
-		}
235
+                if (static::isValidImageHandle($handle)) {
236
+                    break;
237
+                }
238
+            }
239
+        }
241 240
 		
242
-		if (!static::isValidImageHandle($handle)) {
243
-			throw new InvalidImageSourceException("String doesn't contain valid image data.");
244
-		}
241
+        if (!static::isValidImageHandle($handle)) {
242
+            throw new InvalidImageSourceException("String doesn't contain valid image data.");
243
+        }
245 244
 		
246
-		return static::loadFromHandle($handle);
247
-	}
245
+        return static::loadFromHandle($handle);
246
+    }
248 247
 	
249
-	/**
250
-	 * Create and load an image from an image handle.
251
-	 * 
252
-	 * <b>Note:</b> the resulting image object takes ownership of the passed 
253
-	 * handle. When the newly-created image object is destroyed, the handle is 
254
-	 * destroyed too, so it's not a valid image handle anymore. In order to 
255
-	 * preserve the handle for use after object destruction, you have to call 
256
-	 * \WideImage\Image::releaseHandle() on the created image instance prior to its
257
-	 * destruction.
258
-	 * 
259
-	 * <code>
260
-	 * $handle = imagecreatefrompng('file.png');
261
-	 * $image = WideImage::loadFromHandle($handle);
262
-	 * </code>
263
-	 * 
264
-	 * @param resource $handle A valid GD image resource
265
-	 * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
266
-	 */
267
-	public static function loadFromHandle($handle)
268
-	{
269
-		if (!static::isValidImageHandle($handle)) {
270
-			throw new InvalidImageSourceException("Handle is not a valid GD image resource.");
271
-		}
248
+    /**
249
+     * Create and load an image from an image handle.
250
+     * 
251
+     * <b>Note:</b> the resulting image object takes ownership of the passed 
252
+     * handle. When the newly-created image object is destroyed, the handle is 
253
+     * destroyed too, so it's not a valid image handle anymore. In order to 
254
+     * preserve the handle for use after object destruction, you have to call 
255
+     * \WideImage\Image::releaseHandle() on the created image instance prior to its
256
+     * destruction.
257
+     * 
258
+     * <code>
259
+     * $handle = imagecreatefrompng('file.png');
260
+     * $image = WideImage::loadFromHandle($handle);
261
+     * </code>
262
+     * 
263
+     * @param resource $handle A valid GD image resource
264
+     * @return \WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
265
+     */
266
+    public static function loadFromHandle($handle)
267
+    {
268
+        if (!static::isValidImageHandle($handle)) {
269
+            throw new InvalidImageSourceException("Handle is not a valid GD image resource.");
270
+        }
272 271
 		
273
-		if (imageistruecolor($handle)) {
274
-			return new TrueColorImage($handle);
275
-		}
272
+        if (imageistruecolor($handle)) {
273
+            return new TrueColorImage($handle);
274
+        }
276 275
 		
277
-		return new PaletteImage($handle);
278
-	}
276
+        return new PaletteImage($handle);
277
+    }
279 278
 	
280
-	/**
281
-	 * This method loads a file from the $_FILES array. The image format is auto-detected.
282
-	 * 
283
-	 * You only have to pass the field name as the parameter. For array fields, this function will
284
-	 * return an array of image objects, unless you specify the $index parameter, which will
285
-	 * load the desired image.
286
-	 * 
287
-	 * @param $field_name Name of the key in $_FILES array
288
-	 * @param int $index The index of the file to load (if the input field is an array)
289
-	 * @return \WideImage\Image The loaded image
290
-	 */
291
-	public static function loadFromUpload($field_name, $index = null)
292
-	{
293
-		if (!array_key_exists($field_name, $_FILES)) {
294
-			throw new InvalidImageSourceException("Upload field '{$field_name}' doesn't exist.");
295
-		}
279
+    /**
280
+     * This method loads a file from the $_FILES array. The image format is auto-detected.
281
+     * 
282
+     * You only have to pass the field name as the parameter. For array fields, this function will
283
+     * return an array of image objects, unless you specify the $index parameter, which will
284
+     * load the desired image.
285
+     * 
286
+     * @param $field_name Name of the key in $_FILES array
287
+     * @param int $index The index of the file to load (if the input field is an array)
288
+     * @return \WideImage\Image The loaded image
289
+     */
290
+    public static function loadFromUpload($field_name, $index = null)
291
+    {
292
+        if (!array_key_exists($field_name, $_FILES)) {
293
+            throw new InvalidImageSourceException("Upload field '{$field_name}' doesn't exist.");
294
+        }
296 295
 		
297
-		if (is_array($_FILES[$field_name]['tmp_name'])) {
298
-			if (isset($_FILES[$field_name]['tmp_name'][$index])) {
299
-				$filename = $_FILES[$field_name]['tmp_name'][$index];
300
-			} else {
301
-				$result = array();
296
+        if (is_array($_FILES[$field_name]['tmp_name'])) {
297
+            if (isset($_FILES[$field_name]['tmp_name'][$index])) {
298
+                $filename = $_FILES[$field_name]['tmp_name'][$index];
299
+            } else {
300
+                $result = array();
302 301
 				
303
-				foreach ($_FILES[$field_name]['tmp_name'] as $idx => $tmp_name) {
304
-					$result[$idx] = static::loadFromFile($tmp_name);
305
-				}
302
+                foreach ($_FILES[$field_name]['tmp_name'] as $idx => $tmp_name) {
303
+                    $result[$idx] = static::loadFromFile($tmp_name);
304
+                }
306 305
 				
307
-				return $result;
308
-			}
309
-		} else {
310
-			$filename = $_FILES[$field_name]['tmp_name'];
311
-		}
306
+                return $result;
307
+            }
308
+        } else {
309
+            $filename = $_FILES[$field_name]['tmp_name'];
310
+        }
312 311
 		
313
-		if (!file_exists($filename)) {
314
-			throw new InvalidImageSourceException("Uploaded file doesn't exist.");
315
-		}
312
+        if (!file_exists($filename)) {
313
+            throw new InvalidImageSourceException("Uploaded file doesn't exist.");
314
+        }
316 315
 		
317
-		return static::loadFromFile($filename);
318
-	}
316
+        return static::loadFromFile($filename);
317
+    }
319 318
 	
320
-	/**
321
-	 * Factory method for creating a palette image
322
-	 * 
323
-	 * @param int $width
324
-	 * @param int $height
325
-	 * @return \WideImage\PaletteImage
326
-	 */
327
-	public static function createPaletteImage($width, $height)
328
-	{
329
-		return PaletteImage::create($width, $height);
330
-	}
319
+    /**
320
+     * Factory method for creating a palette image
321
+     * 
322
+     * @param int $width
323
+     * @param int $height
324
+     * @return \WideImage\PaletteImage
325
+     */
326
+    public static function createPaletteImage($width, $height)
327
+    {
328
+        return PaletteImage::create($width, $height);
329
+    }
331 330
 	
332
-	/**
333
-	 * Factory method for creating a true-color image
334
-	 * 
335
-	 * @param int $width
336
-	 * @param int $height
337
-	 * @return \WideImage\TrueColorImage
338
-	 */
339
-	public static function createTrueColorImage($width, $height)
340
-	{
341
-		return TrueColorImage::create($width, $height);
342
-	}
331
+    /**
332
+     * Factory method for creating a true-color image
333
+     * 
334
+     * @param int $width
335
+     * @param int $height
336
+     * @return \WideImage\TrueColorImage
337
+     */
338
+    public static function createTrueColorImage($width, $height)
339
+    {
340
+        return TrueColorImage::create($width, $height);
341
+    }
343 342
 	
344
-	/**
345
-	 * Check whether the given handle is a valid GD resource
346
-	 * 
347
-	 * @param mixed $handle The variable to check
348
-	 * @return bool
349
-	 */
350
-	public static function isValidImageHandle($handle)
351
-	{
352
-		return (is_resource($handle) && get_resource_type($handle) == 'gd');
353
-	}
343
+    /**
344
+     * Check whether the given handle is a valid GD resource
345
+     * 
346
+     * @param mixed $handle The variable to check
347
+     * @return bool
348
+     */
349
+    public static function isValidImageHandle($handle)
350
+    {
351
+        return (is_resource($handle) && get_resource_type($handle) == 'gd');
352
+    }
354 353
 	
355
-	/**
356
-	 * Throws exception if the handle isn't a valid GD resource
357
-	 * 
358
-	 * @param mixed $handle The variable to check
359
-	 */
360
-	public static function assertValidImageHandle($handle)
361
-	{
362
-		if (!static::isValidImageHandle($handle)) {
363
-			throw new InvalidImageHandleException("{$handle} is not a valid image handle.");
364
-		}
365
-	}
354
+    /**
355
+     * Throws exception if the handle isn't a valid GD resource
356
+     * 
357
+     * @param mixed $handle The variable to check
358
+     */
359
+    public static function assertValidImageHandle($handle)
360
+    {
361
+        if (!static::isValidImageHandle($handle)) {
362
+            throw new InvalidImageHandleException("{$handle} is not a valid image handle.");
363
+        }
364
+    }
366 365
 }
367 366
 	
368 367
 WideImage::checkGD();
369 368
 
370 369
 WideImage::registerCustomMapper('\\WideImage\\Mapper\\BMP', 'image/bmp', 'bmp');
371 370
 WideImage::registerCustomMapper('\\WideImage\\Mapper\\TGA', 'image/tga', 'tga');
372
-	
373 371
\ No newline at end of file
372
+    
374 373
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	public static function path()
69 69
 	{
70 70
 		if (static::$path === null) {
71
-			static::$path = __DIR__ . DIRECTORY_SEPARATOR;
71
+			static::$path = __DIR__.DIRECTORY_SEPARATOR;
72 72
 		}
73 73
 		
74 74
 		return static::$path;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			$predictedSourceType = 'File';
165 165
 		}
166 166
 		
167
-		return call_user_func(array(__CLASS__, 'loadFrom' . $predictedSourceType), $source);
167
+		return call_user_func(array(__CLASS__, 'loadFrom'.$predictedSourceType), $source);
168 168
 	}
169 169
 
170 170
 	/**
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/Font/GDF.php 1 patch
Indentation   +18 added lines, -19 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 WideImage
22
-  **/
20
+     * @package WideImage
21
+     **/
23 22
 
24 23
 namespace WideImage\Font;
25 24
 
@@ -30,22 +29,22 @@  discard block
 block discarded – undo
30 29
  */
31 30
 class GDF
32 31
 {
33
-	protected $font;
34
-	protected $color;
32
+    protected $font;
33
+    protected $color;
35 34
 	
36
-	public function __construct($face, $color)
37
-	{
38
-		if (is_int($face) && $face >= 1 && $face <= 5) {
39
-			$this->font = $face;
40
-		} else {
41
-			$this->font = imageloadfont($face);
42
-		}
35
+    public function __construct($face, $color)
36
+    {
37
+        if (is_int($face) && $face >= 1 && $face <= 5) {
38
+            $this->font = $face;
39
+        } else {
40
+            $this->font = imageloadfont($face);
41
+        }
43 42
 		
44
-		$this->color = $color;
45
-	}
43
+        $this->color = $color;
44
+    }
46 45
 	
47
-	public function writeText($image, $x, $y, $text)
48
-	{
49
-		imagestring($image->getHandle(), $this->font, $x, $y, $text, $this->color);
50
-	}
46
+    public function writeText($image, $x, $y, $text)
47
+    {
48
+        imagestring($image->getHandle(), $this->font, $x, $y, $text, $this->color);
49
+    }
51 50
 }
Please login to merge, or discard this patch.