Test Failed
Push — master ( 4527f5...6e7815 )
by Ylva
21:41 queued 04:42
created
a/vendor/mos/cimage/CImage.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
     /**
224 224
      * Path to command to optimize jpeg images, for example jpegtran or null.
225 225
      */
226
-     private $jpegOptimize;
227
-     private $jpegOptimizeCmd;
226
+        private $jpegOptimize;
227
+        private $jpegOptimizeCmd;
228 228
 
229 229
 
230 230
 
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 
396 396
 
397 397
     /**
398
-    * Disable the fasttrackCacke to start with, inject an object to enable it.
399
-    */
398
+     * Disable the fasttrackCacke to start with, inject an object to enable it.
399
+     */
400 400
     private $fastTrackCache = null;
401 401
 
402 402
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
     /*
427 427
      * Image copy strategy, defaults to RESAMPLE.
428 428
      */
429
-     const RESIZE = 1;
430
-     const RESAMPLE = 2;
431
-     private $copyStrategy = NULL;
429
+        const RESIZE = 1;
430
+        const RESAMPLE = 2;
431
+        private $copyStrategy = NULL;
432 432
 
433 433
 
434 434
 
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
         $this->crop      = $this->cropOrig;
1254 1254
 
1255 1255
         $this->initDimensions()
1256
-             ->calculateNewWidthAndHeight();
1256
+                ->calculateNewWidthAndHeight();
1257 1257
 
1258 1258
         return $this;
1259 1259
     }
@@ -1684,14 +1684,14 @@  discard block
 block discarded – undo
1684 1684
         if ($this->rotateBefore) {
1685 1685
             $this->log("Rotating image.");
1686 1686
             $this->rotate($this->rotateBefore, $this->bgColor)
1687
-                 ->reCalculateDimensions();
1687
+                    ->reCalculateDimensions();
1688 1688
         }
1689 1689
 
1690 1690
         // Auto-rotate image
1691 1691
         if ($this->autoRotate) {
1692 1692
             $this->log("Auto rotating image.");
1693 1693
             $this->rotateExif()
1694
-                 ->reCalculateDimensions();
1694
+                    ->reCalculateDimensions();
1695 1695
         }
1696 1696
 
1697 1697
         // Scale the original image before starting
@@ -1718,11 +1718,11 @@  discard block
 block discarded – undo
1718 1718
      *
1719 1719
      * @return $this
1720 1720
      */
1721
-     public function setCopyResizeStrategy($strategy)
1722
-     {
1723
-         $this->copyStrategy = $strategy;
1724
-         return $this;
1725
-     }
1721
+        public function setCopyResizeStrategy($strategy)
1722
+        {
1723
+            $this->copyStrategy = $strategy;
1724
+            return $this;
1725
+        }
1726 1726
 
1727 1727
 
1728 1728
 
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
      * @param string $color as hex value.
2234 2234
      *
2235 2235
      * @return $this
2236
-    */
2236
+     */
2237 2237
     public function setDefaultBackgroundColor($color)
2238 2238
     {
2239 2239
         $this->log("Setting default background color to '$color'.");
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
      * @param resource $img the image to work with or null if using $this->image.
2286 2286
      *
2287 2287
      * @return color value or null if no background color is set.
2288
-    */
2288
+     */
2289 2289
     private function getBackgroundColor($img = null)
2290 2290
     {
2291 2291
         $img = isset($img) ? $img : $this->image;
@@ -2319,7 +2319,7 @@  discard block
 block discarded – undo
2319 2319
      * @param int $height of the new image.
2320 2320
      *
2321 2321
      * @return image resource.
2322
-    */
2322
+     */
2323 2323
     private function createImageKeepTransparency($width, $height)
2324 2324
     {
2325 2325
         $this->log("Creating a new working image width={$width}px, height={$height}px.");
@@ -2564,8 +2564,8 @@  discard block
 block discarded – undo
2564 2564
 
2565 2565
         // Prepare
2566 2566
         $this->setSaveFolder($cache)
2567
-             ->setSource($src, $dir)
2568
-             ->generateFilename(null, false, 'srgb_');
2567
+                ->setSource($src, $dir)
2568
+                ->generateFilename(null, false, 'srgb_');
2569 2569
 
2570 2570
         // Check if the cached version is accurate.
2571 2571
         if ($useCache && is_readable($this->cacheFileName)) {
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     /**
232 232
      * Image dimensions, calculated from loaded image.
233 233
      */
234
-    private $width;  // Calculated from source image
234
+    private $width; // Calculated from source image
235 235
     private $height; // Calculated from source image
236 236
 
237 237
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * New image dimensions, incoming as argument or calculated.
240 240
      */
241 241
     private $newWidth;
242
-    private $newWidthOrig;  // Save original value
242
+    private $newWidthOrig; // Save original value
243 243
     private $newHeight;
244 244
     private $newHeightOrig; // Save original value
245 245
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      */
546 546
     public function createDummyImage($width = null, $height = null)
547 547
     {
548
-        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;
548
+        $this->newWidth  = $this->newWidth ?: $width ?: 100;
549 549
         $this->newHeight = $this->newHeight ?: $height ?: 100;
550 550
 
551 551
         $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
                 $parts = explode(',', $filterStr);
876 876
                 $filter = $this->mapFilter($parts[0]);
877 877
                 $filter['str'] = $filterStr;
878
-                for ($i=1; $i<=$filter['argc']; $i++) {
878
+                for ($i = 1; $i <= $filter['argc']; $i++) {
879 879
                     if (isset($parts[$i])) {
880 880
                         $filter["arg{$i}"] = $parts[$i];
881 881
                     } else {
@@ -921,16 +921,16 @@  discard block
 block discarded – undo
921 921
     private function mapFilter($name)
922 922
     {
923 923
         $map = array(
924
-            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),
925
-            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),
926
-            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),
927
-            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),
928
-            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),
929
-            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),
930
-            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),
931
-            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),
932
-            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),
933
-            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),
924
+            'negate'          => array('id'=>0, 'argc'=>0, 'type'=>IMG_FILTER_NEGATE),
925
+            'grayscale'       => array('id'=>1, 'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),
926
+            'brightness'      => array('id'=>2, 'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),
927
+            'contrast'        => array('id'=>3, 'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),
928
+            'colorize'        => array('id'=>4, 'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),
929
+            'edgedetect'      => array('id'=>5, 'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),
930
+            'emboss'          => array('id'=>6, 'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),
931
+            'gaussian_blur'   => array('id'=>7, 'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),
932
+            'selective_blur'  => array('id'=>8, 'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),
933
+            'mean_removal'    => array('id'=>9, 'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),
934 934
             'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),
935 935
             'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),
936 936
         );
@@ -1024,15 +1024,15 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
         // width as %
1026 1026
         if ($this->newWidth
1027
-            && $this->newWidth[strlen($this->newWidth)-1] == '%') {
1028
-            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;
1027
+            && $this->newWidth[strlen($this->newWidth) - 1] == '%') {
1028
+            $this->newWidth = $this->width*substr($this->newWidth, 0, -1)/100;
1029 1029
             $this->log("Setting new width based on % to {$this->newWidth}");
1030 1030
         }
1031 1031
 
1032 1032
         // height as %
1033 1033
         if ($this->newHeight
1034
-            && $this->newHeight[strlen($this->newHeight)-1] == '%') {
1035
-            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;
1034
+            && $this->newHeight[strlen($this->newHeight) - 1] == '%') {
1035
+            $this->newHeight = $this->height*substr($this->newHeight, 0, -1)/100;
1036 1036
             $this->log("Setting new height based on % to {$this->newHeight}");
1037 1037
         }
1038 1038
 
@@ -1042,32 +1042,32 @@  discard block
 block discarded – undo
1042 1042
         if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {
1043 1043
             if ($this->aspectRatio >= 1) {
1044 1044
                 $this->newWidth   = $this->width;
1045
-                $this->newHeight  = $this->width / $this->aspectRatio;
1045
+                $this->newHeight  = $this->width/$this->aspectRatio;
1046 1046
                 $this->log("Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}");
1047 1047
 
1048 1048
             } else {
1049 1049
                 $this->newHeight  = $this->height;
1050
-                $this->newWidth   = $this->height * $this->aspectRatio;
1050
+                $this->newWidth   = $this->height*$this->aspectRatio;
1051 1051
                 $this->log("Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}");
1052 1052
             }
1053 1053
 
1054 1054
         } elseif ($this->aspectRatio && is_null($this->newWidth)) {
1055
-            $this->newWidth   = $this->newHeight * $this->aspectRatio;
1055
+            $this->newWidth = $this->newHeight*$this->aspectRatio;
1056 1056
             $this->log("Setting new width based on aspect ratio to {$this->newWidth}");
1057 1057
 
1058 1058
         } elseif ($this->aspectRatio && is_null($this->newHeight)) {
1059
-            $this->newHeight  = $this->newWidth / $this->aspectRatio;
1059
+            $this->newHeight = $this->newWidth/$this->aspectRatio;
1060 1060
             $this->log("Setting new height based on aspect ratio to {$this->newHeight}");
1061 1061
         }
1062 1062
 
1063 1063
         // Change width & height based on dpr
1064 1064
         if ($this->dpr != 1) {
1065 1065
             if (!is_null($this->newWidth)) {
1066
-                $this->newWidth  = round($this->newWidth * $this->dpr);
1066
+                $this->newWidth = round($this->newWidth*$this->dpr);
1067 1067
                 $this->log("Setting new width based on dpr={$this->dpr} - w={$this->newWidth}");
1068 1068
             }
1069 1069
             if (!is_null($this->newHeight)) {
1070
-                $this->newHeight = round($this->newHeight * $this->dpr);
1070
+                $this->newHeight = round($this->newHeight*$this->dpr);
1071 1071
                 $this->log("Setting new height based on dpr={$this->dpr} - h={$this->newHeight}");
1072 1072
             }
1073 1073
         }
@@ -1102,10 +1102,10 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
         // Check if there is an area to crop off
1104 1104
         if (isset($this->area)) {
1105
-            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);
1106
-            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);
1107
-            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);
1108
-            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);
1105
+            $this->offset['top']    = round($this->area['top']/100*$this->height);
1106
+            $this->offset['right']  = round($this->area['right']/100*$this->width);
1107
+            $this->offset['bottom'] = round($this->area['bottom']/100*$this->height);
1108
+            $this->offset['left']   = round($this->area['left']/100*$this->width);
1109 1109
             $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];
1110 1110
             $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];
1111 1111
             $this->width  = $this->offset['width'];
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
             } elseif ($this->crop['start_x'] == 'right') {
1128 1128
                 $this->crop['start_x'] = $this->width - $width;
1129 1129
             } elseif ($this->crop['start_x'] == 'center') {
1130
-                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);
1130
+                $this->crop['start_x'] = round($this->width/2) - round($width/2);
1131 1131
             }
1132 1132
 
1133 1133
             if ($this->crop['start_y'] == 'top') {
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
             } elseif ($this->crop['start_y'] == 'bottom') {
1136 1136
                 $this->crop['start_y'] = $this->height - $height;
1137 1137
             } elseif ($this->crop['start_y'] == 'center') {
1138
-                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);
1138
+                $this->crop['start_y'] = round($this->height/2) - round($height/2);
1139 1139
             }
1140 1140
 
1141 1141
             $this->log("Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.");
@@ -1156,25 +1156,25 @@  discard block
 block discarded – undo
1156 1156
 
1157 1157
                 // Both new width and height are set.
1158 1158
                 // Use newWidth and newHeigh as max width/height, image should not be larger.
1159
-                $ratioWidth  = $width  / $this->newWidth;
1160
-                $ratioHeight = $height / $this->newHeight;
1159
+                $ratioWidth  = $width/$this->newWidth;
1160
+                $ratioHeight = $height/$this->newHeight;
1161 1161
                 $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;
1162
-                $this->newWidth  = round($width  / $ratio);
1163
-                $this->newHeight = round($height / $ratio);
1162
+                $this->newWidth  = round($width/$ratio);
1163
+                $this->newHeight = round($height/$ratio);
1164 1164
                 $this->log("New width and height was set.");
1165 1165
 
1166 1166
             } elseif (isset($this->newWidth)) {
1167 1167
 
1168 1168
                 // Use new width as max-width
1169
-                $factor = (float)$this->newWidth / (float)$width;
1170
-                $this->newHeight = round($factor * $height);
1169
+                $factor = (float)$this->newWidth/(float)$width;
1170
+                $this->newHeight = round($factor*$height);
1171 1171
                 $this->log("New width was set.");
1172 1172
 
1173 1173
             } elseif (isset($this->newHeight)) {
1174 1174
 
1175 1175
                 // Use new height as max-hight
1176
-                $factor = (float)$this->newHeight / (float)$height;
1177
-                $this->newWidth = round($factor * $width);
1176
+                $factor = (float)$this->newHeight/(float)$height;
1177
+                $this->newWidth = round($factor*$width);
1178 1178
                 $this->log("New height was set.");
1179 1179
 
1180 1180
             } else {
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
             if ($this->cropToFit || $this->fillToFit) {
1190 1190
 
1191 1191
                 // Get relations of original & target image
1192
-                $ratioWidth  = $width  / $this->newWidth;
1193
-                $ratioHeight = $height / $this->newHeight;
1192
+                $ratioWidth  = $width/$this->newWidth;
1193
+                $ratioHeight = $height/$this->newHeight;
1194 1194
 
1195 1195
                 if ($this->cropToFit) {
1196 1196
 
@@ -1198,8 +1198,8 @@  discard block
 block discarded – undo
1198 1198
                     // image should fit the area.
1199 1199
                     $this->log("Crop to fit.");
1200 1200
                     $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;
1201
-                    $this->cropWidth  = round($width  / $ratio);
1202
-                    $this->cropHeight = round($height / $ratio);
1201
+                    $this->cropWidth  = round($width/$ratio);
1202
+                    $this->cropHeight = round($height/$ratio);
1203 1203
                     $this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
1204 1204
 
1205 1205
                 } elseif ($this->fillToFit) {
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
                     // image should fit the area.
1209 1209
                     $this->log("Fill to fit.");
1210 1210
                     $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;
1211
-                    $this->fillWidth  = round($width  / $ratio);
1212
-                    $this->fillHeight = round($height / $ratio);
1211
+                    $this->fillWidth  = round($width/$ratio);
1212
+                    $this->fillHeight = round($height/$ratio);
1213 1213
                     $this->log("Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).");
1214 1214
                 }
1215 1215
             }
@@ -1391,17 +1391,17 @@  discard block
 block discarded – undo
1391 1391
     public function generateFilename($base = null, $useSubdir = true, $prefix = null)
1392 1392
     {
1393 1393
         $filename     = basename($this->pathToImage);
1394
-        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;
1395
-        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;
1396
-        $crop_x       = $this->crop_x       ? "_x{$this->crop_x}"        : null;
1397
-        $crop_y       = $this->crop_y       ? "_y{$this->crop_y}"        : null;
1398
-        $scale        = $this->scale        ? "_s{$this->scale}"         : null;
1399
-        $bgColor      = $this->bgColor      ? "_bgc{$this->bgColor}"     : null;
1400
-        $quality      = $this->quality      ? "_q{$this->quality}"       : null;
1401
-        $compress     = $this->compress     ? "_co{$this->compress}"     : null;
1394
+        $cropToFit    = $this->cropToFit ? '_cf' : null;
1395
+        $fillToFit    = $this->fillToFit ? '_ff' : null;
1396
+        $crop_x       = $this->crop_x ? "_x{$this->crop_x}" : null;
1397
+        $crop_y       = $this->crop_y ? "_y{$this->crop_y}" : null;
1398
+        $scale        = $this->scale ? "_s{$this->scale}" : null;
1399
+        $bgColor      = $this->bgColor ? "_bgc{$this->bgColor}" : null;
1400
+        $quality      = $this->quality ? "_q{$this->quality}" : null;
1401
+        $compress     = $this->compress ? "_co{$this->compress}" : null;
1402 1402
         $rotateBefore = $this->rotateBefore ? "_rb{$this->rotateBefore}" : null;
1403
-        $rotateAfter  = $this->rotateAfter  ? "_ra{$this->rotateAfter}"  : null;
1404
-        $lossy        = $this->lossy        ? "_l"                       : null;
1403
+        $rotateAfter  = $this->rotateAfter ? "_ra{$this->rotateAfter}" : null;
1404
+        $lossy        = $this->lossy ? "_l" : null;
1405 1405
 
1406 1406
         $saveAs = $this->normalizeFileExtension();
1407 1407
         $saveAs = $saveAs ? "_$saveAs" : null;
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
             $copyStrat = "_rs";
1412 1412
         }
1413 1413
 
1414
-        $width  = $this->newWidth  ? '_' . $this->newWidth  : null;
1414
+        $width  = $this->newWidth ? '_' . $this->newWidth : null;
1415 1415
         $height = $this->newHeight ? '_' . $this->newHeight : null;
1416 1416
 
1417 1417
         $offset = isset($this->offset)
@@ -1427,23 +1427,23 @@  discard block
 block discarded – undo
1427 1427
             foreach ($this->filters as $filter) {
1428 1428
                 if (is_array($filter)) {
1429 1429
                     $filters .= "_f{$filter['id']}";
1430
-                    for ($i=1; $i<=$filter['argc']; $i++) {
1431
-                        $filters .= "-".$filter["arg{$i}"];
1430
+                    for ($i = 1; $i <= $filter['argc']; $i++) {
1431
+                        $filters .= "-" . $filter["arg{$i}"];
1432 1432
                     }
1433 1433
                 }
1434 1434
             }
1435 1435
         }
1436 1436
 
1437 1437
         $sharpen = $this->sharpen ? 's' : null;
1438
-        $emboss  = $this->emboss  ? 'e' : null;
1439
-        $blur    = $this->blur    ? 'b' : null;
1438
+        $emboss  = $this->emboss ? 'e' : null;
1439
+        $blur    = $this->blur ? 'b' : null;
1440 1440
         $palette = $this->palette ? 'p' : null;
1441 1441
 
1442 1442
         $autoRotate = $this->autoRotate ? 'ar' : null;
1443 1443
 
1444 1444
         $optimize  = $this->jpegOptimize ? 'o' : null;
1445
-        $optimize .= $this->pngFilter    ? 'f' : null;
1446
-        $optimize .= $this->pngDeflate   ? 'd' : null;
1445
+        $optimize .= $this->pngFilter ? 'f' : null;
1446
+        $optimize .= $this->pngDeflate ? 'd' : null;
1447 1447
 
1448 1448
         $convolve = null;
1449 1449
         if ($this->convolve) {
@@ -1657,9 +1657,9 @@  discard block
 block discarded – undo
1657 1657
             $h = imagesy($im);
1658 1658
             $w = imagesx($im);
1659 1659
             $c = array();
1660
-            for ($x=0; $x < $w; $x++) {
1661
-                for ($y=0; $y < $h; $y++) {
1662
-                    @$c['c'.imagecolorat($im, $x, $y)]++;
1660
+            for ($x = 0; $x < $w; $x++) {
1661
+                for ($y = 0; $y < $h; $y++) {
1662
+                    @$c['c' . imagecolorat($im, $x, $y)]++;
1663 1663
                 }
1664 1664
             }
1665 1665
             return count($c);
@@ -1697,8 +1697,8 @@  discard block
 block discarded – undo
1697 1697
         // Scale the original image before starting
1698 1698
         if (isset($this->scale)) {
1699 1699
             $this->log("Scale by {$this->scale}%");
1700
-            $newWidth  = $this->width * $this->scale / 100;
1701
-            $newHeight = $this->height * $this->scale / 100;
1700
+            $newWidth  = $this->width*$this->scale/100;
1701
+            $newHeight = $this->height*$this->scale/100;
1702 1702
             $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);
1703 1703
             imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);
1704 1704
             $this->image = $img;
@@ -1733,7 +1733,7 @@  discard block
 block discarded – undo
1733 1733
      */
1734 1734
     public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
1735 1735
     {
1736
-        if($this->copyStrategy == self::RESIZE) {
1736
+        if ($this->copyStrategy == self::RESIZE) {
1737 1737
             $this->log("Copy by resize");
1738 1738
             imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
1739 1739
         } else {
@@ -1798,14 +1798,14 @@  discard block
 block discarded – undo
1798 1798
                 $cropY = 0;
1799 1799
 
1800 1800
                 if ($this->newWidth > $this->width) {
1801
-                    $posX = round(($this->newWidth - $this->width) / 2);
1801
+                    $posX = round(($this->newWidth - $this->width)/2);
1802 1802
                 }
1803 1803
                 if ($this->newWidth < $this->width) {
1804 1804
                     $cropX = round(($this->width/2) - ($this->newWidth/2));
1805 1805
                 }
1806 1806
 
1807 1807
                 if ($this->newHeight > $this->height) {
1808
-                    $posY = round(($this->newHeight - $this->height) / 2);
1808
+                    $posY = round(($this->newHeight - $this->height)/2);
1809 1809
                 }
1810 1810
                 if ($this->newHeight < $this->height) {
1811 1811
                     $cropY = round(($this->height/2) - ($this->newHeight/2));
@@ -1844,14 +1844,14 @@  discard block
 block discarded – undo
1844 1844
             $posX = 0;
1845 1845
             $posY = 0;
1846 1846
 
1847
-            $ratioOrig = $this->width / $this->height;
1848
-            $ratioNew  = $this->newWidth / $this->newHeight;
1847
+            $ratioOrig = $this->width/$this->height;
1848
+            $ratioNew  = $this->newWidth/$this->newHeight;
1849 1849
 
1850 1850
             // Check ratio for landscape or portrait
1851 1851
             if ($ratioOrig < $ratioNew) {
1852
-                $posX = round(($this->newWidth - $this->fillWidth) / 2);
1852
+                $posX = round(($this->newWidth - $this->fillWidth)/2);
1853 1853
             } else {
1854
-                $posY = round(($this->newHeight - $this->fillHeight) / 2);
1854
+                $posY = round(($this->newHeight - $this->fillHeight)/2);
1855 1855
             }
1856 1856
 
1857 1857
             if (!$this->upscale
@@ -1859,8 +1859,8 @@  discard block
 block discarded – undo
1859 1859
             ) {
1860 1860
 
1861 1861
                 $this->log("Resizing - smaller image, do not upscale.");
1862
-                $posX = round(($this->newWidth - $this->width) / 2);
1863
-                $posY = round(($this->newHeight - $this->height) / 2);
1862
+                $posX = round(($this->newWidth - $this->width)/2);
1863
+                $posY = round(($this->newHeight - $this->height)/2);
1864 1864
                 $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
1865 1865
                 imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
1866 1866
 
@@ -1894,14 +1894,14 @@  discard block
 block discarded – undo
1894 1894
                     $cropY = 0;
1895 1895
 
1896 1896
                     if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
1897
-                        $posX = round(($this->newWidth - $this->width) / 2);
1898
-                        $posY = round(($this->newHeight - $this->height) / 2);
1897
+                        $posX = round(($this->newWidth - $this->width)/2);
1898
+                        $posY = round(($this->newHeight - $this->height)/2);
1899 1899
                     } elseif ($this->newWidth > $this->width) {
1900
-                        $posX = round(($this->newWidth - $this->width) / 2);
1901
-                        $cropY = round(($this->height - $this->newHeight) / 2);
1900
+                        $posX = round(($this->newWidth - $this->width)/2);
1901
+                        $cropY = round(($this->height - $this->newHeight)/2);
1902 1902
                     } elseif ($this->newHeight > $this->height) {
1903
-                        $posY = round(($this->newHeight - $this->height) / 2);
1904
-                        $cropX = round(($this->width - $this->newWidth) / 2);
1903
+                        $posY = round(($this->newHeight - $this->height)/2);
1904
+                        $cropX = round(($this->width - $this->newWidth)/2);
1905 1905
                     }
1906 1906
 
1907 1907
                     $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
             );
2165 2165
         }
2166 2166
 
2167
-        array_walk($part, function ($item, $key) {
2167
+        array_walk($part, function($item, $key) {
2168 2168
             if (!is_numeric($item)) {
2169 2169
                 throw new Exception("Argument to convolve expression should be float but is not.");
2170 2170
             }
@@ -2436,7 +2436,7 @@  discard block
 block discarded – undo
2436 2436
 
2437 2437
         $type = $this->getTargetImageExtension();
2438 2438
         $this->Log("Saving image as " . $type);
2439
-        switch($type) {
2439
+        switch ($type) {
2440 2440
 
2441 2441
             case 'jpeg':
2442 2442
             case 'jpg':
@@ -2788,16 +2788,16 @@  discard block
 block discarded – undo
2788 2788
         $details['mimeType']    = $this->getMimeType($this->fileType);
2789 2789
         $details['width']       = $this->width;
2790 2790
         $details['height']      = $this->height;
2791
-        $details['aspectRatio'] = round($this->width / $this->height, 3);
2791
+        $details['aspectRatio'] = round($this->width/$this->height, 3);
2792 2792
         $details['size']        = filesize($file);
2793 2793
         $details['colors'] = $this->colorsTotal($this->image);
2794 2794
         $details['includedFiles'] = count(get_included_files());
2795
-        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ;
2795
+        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB";
2796 2796
         $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB";
2797 2797
         $details['memoryLimit'] = ini_get('memory_limit');
2798 2798
 
2799 2799
         if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
2800
-            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
2800
+            $details['loadTime'] = (string)round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
2801 2801
         }
2802 2802
 
2803 2803
         if ($details['mimeType'] == 'image/png') {
@@ -2889,7 +2889,7 @@  discard block
 block discarded – undo
2889 2889
         $log = null;
2890 2890
         $this->log("### Summary of verbose log");
2891 2891
         $this->log("As JSON: \n" . $this->json());
2892
-        $this->log("Memory peak: " . round(memory_get_peak_usage() /1024/1024) . "M");
2892
+        $this->log("Memory peak: " . round(memory_get_peak_usage()/1024/1024) . "M");
2893 2893
         $this->log("Memory limit: " . ini_get('memory_limit'));
2894 2894
 
2895 2895
         $included = get_included_files();
Please login to merge, or discard this patch.
a/vendor/mos/cimage/autoload.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
  *
16 16
  * @return void
17 17
  */
18
-spl_autoload_register(function ($class) {
18
+spl_autoload_register(function($class) {
19 19
     //$path = CIMAGE_SOURCE_PATH . "/{$class}.php";
20 20
     $path = __DIR__ . "/{$class}.php";
21 21
     if (is_file($path)) {
Please login to merge, or discard this patch.
a/vendor/mos/cimage/CAsciiArt.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 
117 117
         $ascii = null;
118 118
         $incY = $this->scale;
119
-        $incX = $this->scale / 2;
119
+        $incX = $this->scale/2;
120 120
         
121 121
         for ($y = 0; $y < $height - 1; $y += $incY) {
122 122
             for ($x = 0; $x < $width - 1; $x += $incX) {
123
-                $toX = min($x + $this->scale / 2, $width - 1);
123
+                $toX = min($x + $this->scale/2, $width - 1);
124 124
                 $toY = min($y + $this->scale, $height - 1);
125 125
                 $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);
126 126
                 $ascii .= $this->luminance2character($luminance);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)
148 148
     {
149
-        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);
149
+        $numPixels = ($x2 - $x1 + 1)*($y2 - $y1 + 1);
150 150
         $luminance = 0;
151 151
         
152 152
         for ($x = $x1; $x <= $x2; $x++) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             }
160 160
         }
161 161
         
162
-        return $luminance / $numPixels;
162
+        return $luminance/$numPixels;
163 163
     }
164 164
 
165 165
 
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
     {
178 178
         switch ($this->luminanceStrategy) {
179 179
             case 1:
180
-                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
180
+                $luminance = ($red*0.2126 + $green*0.7152 + $blue*0.0722)/255;
181 181
                 break;
182 182
             case 2:
183
-                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;
183
+                $luminance = ($red*0.299 + $green*0.587 + $blue*0.114)/255;
184 184
                 break;
185 185
             case 3:
186
-                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;
186
+                $luminance = sqrt(0.299*pow($red, 2) + 0.587*pow($green, 2) + 0.114*pow($blue, 2))/255;
187 187
                 break;
188 188
             case 0:
189 189
             default:
190
-                $luminance = ($red + $green + $blue) / (255 * 3);
190
+                $luminance = ($red + $green + $blue)/(255*3);
191 191
         }
192 192
 
193 193
         return $luminance;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function luminance2character($luminance)
207 207
     {
208
-        $position = (int) round($luminance * ($this->charCount - 1));
208
+        $position = (int)round($luminance*($this->charCount - 1));
209 209
         $char = $this->characters[$position];
210 210
         return $char;
211 211
     }
Please login to merge, or discard this patch.
a/vendor/mos/cimage/webroot/img_config.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
      * Default values:
41 41
      *  mode: 'production'
42 42
      */
43
-     //'mode' => 'production',
44
-     'mode' => 'development',
45
-     //'mode' => 'strict',
43
+        //'mode' => 'production',
44
+        'mode' => 'development',
45
+        //'mode' => 'strict',
46 46
 
47 47
 
48 48
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
      *  CCache: CCache
94 94
      *  CFastTrackCache: CFastTrackCache
95 95
      */
96
-     //'CImage' => 'CImage',
97
-     //'CCache' => 'CCache',
98
-     //'CFastTrackCache' => 'CFastTrackCache',
96
+        //'CImage' => 'CImage',
97
+        //'CCache' => 'CCache',
98
+        //'CFastTrackCache' => 'CFastTrackCache',
99 99
 
100 100
 
101 101
 
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
      * Default value:
161 161
      *  src_alt:  null //disabled by default
162 162
      */
163
-     //'src_alt' => 'car.png',
164
-     //'src_alt' => 'dummy',
163
+        //'src_alt' => 'car.png',
164
+        //'src_alt' => 'dummy',
165 165
 
166 166
 
167 167
 
@@ -172,62 +172,62 @@  discard block
 block discarded – undo
172 172
      *  valid_filename:  '#^[a-z0-9A-Z-/_ \.:]+$#'
173 173
      *  valid_aliasname: '#^[a-z0-9A-Z-_]+$#'
174 174
      */
175
-     //'valid_filename'  => '#^[a-z0-9A-Z-/_ \.:]+$#',
176
-     //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',
177
-
178
-
179
-
180
-     /**
181
-      * Change the default values for CImage quality and compression used
182
-      * when saving images.
183
-      *
184
-      * Default value:
185
-      *  jpg_quality:     null, integer between 0-100
186
-      *  png_compression: null, integer between 0-9
187
-      */
188
-      //'jpg_quality'  => 75,
189
-      //'png_compression' => 1,
190
-
191
-
192
-
193
-      /**
194
-       * Convert the image to srgb before processing. Saves the converted
195
-       * image in a cache subdir 'srgb'. This option is default false but can
196
-       * be changed to default true to do this conversion for all images.
197
-       * This option requires PHP extension imagick and will silently fail
198
-       * if that is not installed.
199
-       *
200
-       * Default value:
201
-       *  srgb_default:      false
202
-       *  srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'
203
-       */
204
-       //'srgb_default' => false,
205
-       //'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',
206
-
207
-
208
-
209
-       /**
210
-        * Set skip-original to true to always process the image and use
211
-        * the cached version. Default is false and to use the original
212
-        * image when its no processing needed.
213
-        *
214
-        * Default value:
215
-        *  skip_original: false
216
-        */
175
+        //'valid_filename'  => '#^[a-z0-9A-Z-/_ \.:]+$#',
176
+        //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',
177
+
178
+
179
+
180
+        /**
181
+         * Change the default values for CImage quality and compression used
182
+         * when saving images.
183
+         *
184
+         * Default value:
185
+         *  jpg_quality:     null, integer between 0-100
186
+         *  png_compression: null, integer between 0-9
187
+         */
188
+        //'jpg_quality'  => 75,
189
+        //'png_compression' => 1,
190
+
191
+
192
+
193
+        /**
194
+         * Convert the image to srgb before processing. Saves the converted
195
+         * image in a cache subdir 'srgb'. This option is default false but can
196
+         * be changed to default true to do this conversion for all images.
197
+         * This option requires PHP extension imagick and will silently fail
198
+         * if that is not installed.
199
+         *
200
+         * Default value:
201
+         *  srgb_default:      false
202
+         *  srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'
203
+         */
204
+        //'srgb_default' => false,
205
+        //'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',
206
+
207
+
208
+
209
+        /**
210
+         * Set skip-original to true to always process the image and use
211
+         * the cached version. Default is false and to use the original
212
+         * image when its no processing needed.
213
+         *
214
+         * Default value:
215
+         *  skip_original: false
216
+         */
217 217
         //'skip_original' => true,
218 218
 
219 219
 
220 220
 
221
-      /**
222
-       * A function (hook) can be called after img.php has processed all
223
-       * configuration options and before processing the image using CImage.
224
-       * The function receives the $img variabel and an array with the
225
-       * majority of current settings.
226
-       *
227
-       * Default value:
228
-       *  hook_before_CImage:     null
229
-       */
230
-       /*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
221
+        /**
222
+         * A function (hook) can be called after img.php has processed all
223
+         * configuration options and before processing the image using CImage.
224
+         * The function receives the $img variabel and an array with the
225
+         * majority of current settings.
226
+         *
227
+         * Default value:
228
+         *  hook_before_CImage:     null
229
+         */
230
+        /*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
231 231
            if ($allConfig['newWidth'] > 10) {
232 232
                $allConfig['newWidth'] *= 2;
233 233
            }
@@ -236,53 +236,53 @@  discard block
 block discarded – undo
236 236
 
237 237
 
238 238
 
239
-       /**
240
-        * Add header for cache control when outputting images.
241
-        *
242
-        * Default value:
243
-        *  cache_control: null, or set to string
244
-        */
239
+        /**
240
+         * Add header for cache control when outputting images.
241
+         *
242
+         * Default value:
243
+         *  cache_control: null, or set to string
244
+         */
245 245
         //'cache_control' => "max-age=86400",
246 246
 
247 247
 
248 248
 
249
-     /**
250
-      * The name representing a dummy image which is automatically created
251
-      * and stored as a image in the dir CACHE_PATH/dummy. The dummy image
252
-      * can then be used as a placeholder image.
253
-      * The dir CACHE_PATH/dummy is automatically created when needed.
254
-      * Write protect the CACHE_PATH/dummy to prevent creation of new
255
-      * dummy images, but continue to use the existing ones.
256
-      *
257
-      * Default value:
258
-      *  dummy_enabled:  true as default, disable dummy feature by setting
259
-      *                  to false.
260
-      *  dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
261
-      */
262
-      //'dummy_enabled' => true,
263
-      //'dummy_filename' => 'dummy',
264
-
265
-
266
-
267
-     /**
268
-     * Check that the imagefile is a file below 'image_path' using realpath().
269
-     * Security constraint to avoid reaching images outside image_path.
270
-     * This means that symbolic links to images outside the image_path will
271
-     * fail.
272
-     *
273
-     * Default value:
274
-     *  image_path_constraint: true
275
-     */
276
-     //'image_path_constraint' => false,
277
-
278
-
279
-
280
-     /**
281
-     * Set default timezone.
282
-     *
283
-     * Default values.
284
-     *  default_timezone: ini_get('default_timezone') or 'UTC'
285
-     */
249
+        /**
250
+         * The name representing a dummy image which is automatically created
251
+         * and stored as a image in the dir CACHE_PATH/dummy. The dummy image
252
+         * can then be used as a placeholder image.
253
+         * The dir CACHE_PATH/dummy is automatically created when needed.
254
+         * Write protect the CACHE_PATH/dummy to prevent creation of new
255
+         * dummy images, but continue to use the existing ones.
256
+         *
257
+         * Default value:
258
+         *  dummy_enabled:  true as default, disable dummy feature by setting
259
+         *                  to false.
260
+         *  dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
261
+         */
262
+        //'dummy_enabled' => true,
263
+        //'dummy_filename' => 'dummy',
264
+
265
+
266
+
267
+        /**
268
+         * Check that the imagefile is a file below 'image_path' using realpath().
269
+         * Security constraint to avoid reaching images outside image_path.
270
+         * This means that symbolic links to images outside the image_path will
271
+         * fail.
272
+         *
273
+         * Default value:
274
+         *  image_path_constraint: true
275
+         */
276
+        //'image_path_constraint' => false,
277
+
278
+
279
+
280
+        /**
281
+         * Set default timezone.
282
+         *
283
+         * Default values.
284
+         *  default_timezone: ini_get('default_timezone') or 'UTC'
285
+         */
286 286
     //'default_timezone' => 'UTC',
287 287
 
288 288
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
      *  allow_hotlinking:     true
389 389
      *  hotlinking_whitelist: array()
390 390
      */
391
-     /*
391
+        /*
392 392
     'allow_hotlinking' => false,
393 393
     'hotlinking_whitelist' => array(
394 394
         '^dbwebb\.se$',
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      *      'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
405 405
      *  )
406 406
      */
407
-     /*
407
+        /*
408 408
     'shortcut' => array(
409 409
         'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
410 410
     ),*/
Please login to merge, or discard this patch.
a/vendor/mos/cimage/webroot/imgp.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
     /**
237
-    * Constructor
238
-    *
239
-    */
237
+     * Constructor
238
+     *
239
+     */
240 240
     public function __construct()
241 241
     {
242 242
         $this->request['header'] = array();
@@ -1333,8 +1333,8 @@  discard block
 block discarded – undo
1333 1333
     /**
1334 1334
      * Path to command to optimize jpeg images, for example jpegtran or null.
1335 1335
      */
1336
-     private $jpegOptimize;
1337
-     private $jpegOptimizeCmd;
1336
+        private $jpegOptimize;
1337
+        private $jpegOptimizeCmd;
1338 1338
 
1339 1339
 
1340 1340
 
@@ -1505,8 +1505,8 @@  discard block
 block discarded – undo
1505 1505
 
1506 1506
 
1507 1507
     /**
1508
-    * Disable the fasttrackCacke to start with, inject an object to enable it.
1509
-    */
1508
+     * Disable the fasttrackCacke to start with, inject an object to enable it.
1509
+     */
1510 1510
     private $fastTrackCache = null;
1511 1511
 
1512 1512
 
@@ -1536,9 +1536,9 @@  discard block
 block discarded – undo
1536 1536
     /*
1537 1537
      * Image copy strategy, defaults to RESAMPLE.
1538 1538
      */
1539
-     const RESIZE = 1;
1540
-     const RESAMPLE = 2;
1541
-     private $copyStrategy = NULL;
1539
+        const RESIZE = 1;
1540
+        const RESAMPLE = 2;
1541
+        private $copyStrategy = NULL;
1542 1542
 
1543 1543
 
1544 1544
 
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
         $this->crop      = $this->cropOrig;
2364 2364
 
2365 2365
         $this->initDimensions()
2366
-             ->calculateNewWidthAndHeight();
2366
+                ->calculateNewWidthAndHeight();
2367 2367
 
2368 2368
         return $this;
2369 2369
     }
@@ -2794,14 +2794,14 @@  discard block
 block discarded – undo
2794 2794
         if ($this->rotateBefore) {
2795 2795
             $this->log("Rotating image.");
2796 2796
             $this->rotate($this->rotateBefore, $this->bgColor)
2797
-                 ->reCalculateDimensions();
2797
+                    ->reCalculateDimensions();
2798 2798
         }
2799 2799
 
2800 2800
         // Auto-rotate image
2801 2801
         if ($this->autoRotate) {
2802 2802
             $this->log("Auto rotating image.");
2803 2803
             $this->rotateExif()
2804
-                 ->reCalculateDimensions();
2804
+                    ->reCalculateDimensions();
2805 2805
         }
2806 2806
 
2807 2807
         // Scale the original image before starting
@@ -2828,11 +2828,11 @@  discard block
 block discarded – undo
2828 2828
      *
2829 2829
      * @return $this
2830 2830
      */
2831
-     public function setCopyResizeStrategy($strategy)
2832
-     {
2833
-         $this->copyStrategy = $strategy;
2834
-         return $this;
2835
-     }
2831
+        public function setCopyResizeStrategy($strategy)
2832
+        {
2833
+            $this->copyStrategy = $strategy;
2834
+            return $this;
2835
+        }
2836 2836
 
2837 2837
 
2838 2838
 
@@ -3343,7 +3343,7 @@  discard block
 block discarded – undo
3343 3343
      * @param string $color as hex value.
3344 3344
      *
3345 3345
      * @return $this
3346
-    */
3346
+     */
3347 3347
     public function setDefaultBackgroundColor($color)
3348 3348
     {
3349 3349
         $this->log("Setting default background color to '$color'.");
@@ -3395,7 +3395,7 @@  discard block
 block discarded – undo
3395 3395
      * @param resource $img the image to work with or null if using $this->image.
3396 3396
      *
3397 3397
      * @return color value or null if no background color is set.
3398
-    */
3398
+     */
3399 3399
     private function getBackgroundColor($img = null)
3400 3400
     {
3401 3401
         $img = isset($img) ? $img : $this->image;
@@ -3429,7 +3429,7 @@  discard block
 block discarded – undo
3429 3429
      * @param int $height of the new image.
3430 3430
      *
3431 3431
      * @return image resource.
3432
-    */
3432
+     */
3433 3433
     private function createImageKeepTransparency($width, $height)
3434 3434
     {
3435 3435
         $this->log("Creating a new working image width={$width}px, height={$height}px.");
@@ -3674,8 +3674,8 @@  discard block
 block discarded – undo
3674 3674
 
3675 3675
         // Prepare
3676 3676
         $this->setSaveFolder($cache)
3677
-             ->setSource($src, $dir)
3678
-             ->generateFilename(null, false, 'srgb_');
3677
+                ->setSource($src, $dir)
3678
+                ->generateFilename(null, false, 'srgb_');
3679 3679
 
3680 3680
         // Check if the cached version is accurate.
3681 3681
         if ($useCache && is_readable($this->cacheFileName)) {
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         $url .= $parts['host'];
264 264
         $url .= isset($parts['port'])
265 265
             ? ":" . $parts['port']
266
-            : "" ;
266
+            : "";
267 267
         $url .= $parts['path'];
268 268
 
269 269
         return $url;
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     public function getStatus()
410 410
     {
411 411
         return isset($this->response['header']['status'])
412
-            ? (int) $this->response['header']['status']
412
+            ? (int)$this->response['header']['status']
413 413
             : null;
414 414
     }
415 415
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
             // max-age=2592000
485 485
             $part = explode('=', $cacheControl);
486 486
             $maxAge = ($part[0] == "max-age")
487
-                ? (int) $part[1]
487
+                ? (int)$part[1]
488 488
                 : null;
489 489
         }
490 490
 
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
             $cimageVersion = CIMAGE_USER_AGENT;
668 668
         }
669 669
         
670
-        $this->http->setHeader("User-Agent", "$cimageVersion (PHP/". phpversion() . " cURL)");
670
+        $this->http->setHeader("User-Agent", "$cimageVersion (PHP/" . phpversion() . " cURL)");
671 671
         $this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
672 672
 
673 673
         if ($this->useCache) {
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
 
1013 1013
         $ascii = null;
1014 1014
         $incY = $this->scale;
1015
-        $incX = $this->scale / 2;
1015
+        $incX = $this->scale/2;
1016 1016
         
1017 1017
         for ($y = 0; $y < $height - 1; $y += $incY) {
1018 1018
             for ($x = 0; $x < $width - 1; $x += $incX) {
1019
-                $toX = min($x + $this->scale / 2, $width - 1);
1019
+                $toX = min($x + $this->scale/2, $width - 1);
1020 1020
                 $toY = min($y + $this->scale, $height - 1);
1021 1021
                 $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);
1022 1022
                 $ascii .= $this->luminance2character($luminance);
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
      */
1043 1043
     public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)
1044 1044
     {
1045
-        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);
1045
+        $numPixels = ($x2 - $x1 + 1)*($y2 - $y1 + 1);
1046 1046
         $luminance = 0;
1047 1047
         
1048 1048
         for ($x = $x1; $x <= $x2; $x++) {
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
             }
1056 1056
         }
1057 1057
         
1058
-        return $luminance / $numPixels;
1058
+        return $luminance/$numPixels;
1059 1059
     }
1060 1060
 
1061 1061
 
@@ -1073,17 +1073,17 @@  discard block
 block discarded – undo
1073 1073
     {
1074 1074
         switch ($this->luminanceStrategy) {
1075 1075
             case 1:
1076
-                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
1076
+                $luminance = ($red*0.2126 + $green*0.7152 + $blue*0.0722)/255;
1077 1077
                 break;
1078 1078
             case 2:
1079
-                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;
1079
+                $luminance = ($red*0.299 + $green*0.587 + $blue*0.114)/255;
1080 1080
                 break;
1081 1081
             case 3:
1082
-                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;
1082
+                $luminance = sqrt(0.299*pow($red, 2) + 0.587*pow($green, 2) + 0.114*pow($blue, 2))/255;
1083 1083
                 break;
1084 1084
             case 0:
1085 1085
             default:
1086
-                $luminance = ($red + $green + $blue) / (255 * 3);
1086
+                $luminance = ($red + $green + $blue)/(255*3);
1087 1087
         }
1088 1088
 
1089 1089
         return $luminance;
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
      */
1102 1102
     public function luminance2character($luminance)
1103 1103
     {
1104
-        $position = (int) round($luminance * ($this->charCount - 1));
1104
+        $position = (int)round($luminance*($this->charCount - 1));
1105 1105
         $char = $this->characters[$position];
1106 1106
         return $char;
1107 1107
     }
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
     /**
1342 1342
      * Image dimensions, calculated from loaded image.
1343 1343
      */
1344
-    private $width;  // Calculated from source image
1344
+    private $width; // Calculated from source image
1345 1345
     private $height; // Calculated from source image
1346 1346
 
1347 1347
 
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
      * New image dimensions, incoming as argument or calculated.
1350 1350
      */
1351 1351
     private $newWidth;
1352
-    private $newWidthOrig;  // Save original value
1352
+    private $newWidthOrig; // Save original value
1353 1353
     private $newHeight;
1354 1354
     private $newHeightOrig; // Save original value
1355 1355
 
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
      */
1656 1656
     public function createDummyImage($width = null, $height = null)
1657 1657
     {
1658
-        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;
1658
+        $this->newWidth  = $this->newWidth ?: $width ?: 100;
1659 1659
         $this->newHeight = $this->newHeight ?: $height ?: 100;
1660 1660
 
1661 1661
         $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
                 $parts = explode(',', $filterStr);
1986 1986
                 $filter = $this->mapFilter($parts[0]);
1987 1987
                 $filter['str'] = $filterStr;
1988
-                for ($i=1; $i<=$filter['argc']; $i++) {
1988
+                for ($i = 1; $i <= $filter['argc']; $i++) {
1989 1989
                     if (isset($parts[$i])) {
1990 1990
                         $filter["arg{$i}"] = $parts[$i];
1991 1991
                     } else {
@@ -2031,16 +2031,16 @@  discard block
 block discarded – undo
2031 2031
     private function mapFilter($name)
2032 2032
     {
2033 2033
         $map = array(
2034
-            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),
2035
-            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),
2036
-            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),
2037
-            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),
2038
-            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),
2039
-            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),
2040
-            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),
2041
-            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),
2042
-            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),
2043
-            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),
2034
+            'negate'          => array('id'=>0, 'argc'=>0, 'type'=>IMG_FILTER_NEGATE),
2035
+            'grayscale'       => array('id'=>1, 'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),
2036
+            'brightness'      => array('id'=>2, 'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),
2037
+            'contrast'        => array('id'=>3, 'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),
2038
+            'colorize'        => array('id'=>4, 'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),
2039
+            'edgedetect'      => array('id'=>5, 'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),
2040
+            'emboss'          => array('id'=>6, 'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),
2041
+            'gaussian_blur'   => array('id'=>7, 'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),
2042
+            'selective_blur'  => array('id'=>8, 'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),
2043
+            'mean_removal'    => array('id'=>9, 'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),
2044 2044
             'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),
2045 2045
             'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),
2046 2046
         );
@@ -2134,15 +2134,15 @@  discard block
 block discarded – undo
2134 2134
 
2135 2135
         // width as %
2136 2136
         if ($this->newWidth
2137
-            && $this->newWidth[strlen($this->newWidth)-1] == '%') {
2138
-            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;
2137
+            && $this->newWidth[strlen($this->newWidth) - 1] == '%') {
2138
+            $this->newWidth = $this->width*substr($this->newWidth, 0, -1)/100;
2139 2139
             $this->log("Setting new width based on % to {$this->newWidth}");
2140 2140
         }
2141 2141
 
2142 2142
         // height as %
2143 2143
         if ($this->newHeight
2144
-            && $this->newHeight[strlen($this->newHeight)-1] == '%') {
2145
-            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;
2144
+            && $this->newHeight[strlen($this->newHeight) - 1] == '%') {
2145
+            $this->newHeight = $this->height*substr($this->newHeight, 0, -1)/100;
2146 2146
             $this->log("Setting new height based on % to {$this->newHeight}");
2147 2147
         }
2148 2148
 
@@ -2152,32 +2152,32 @@  discard block
 block discarded – undo
2152 2152
         if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {
2153 2153
             if ($this->aspectRatio >= 1) {
2154 2154
                 $this->newWidth   = $this->width;
2155
-                $this->newHeight  = $this->width / $this->aspectRatio;
2155
+                $this->newHeight  = $this->width/$this->aspectRatio;
2156 2156
                 $this->log("Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}");
2157 2157
 
2158 2158
             } else {
2159 2159
                 $this->newHeight  = $this->height;
2160
-                $this->newWidth   = $this->height * $this->aspectRatio;
2160
+                $this->newWidth   = $this->height*$this->aspectRatio;
2161 2161
                 $this->log("Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}");
2162 2162
             }
2163 2163
 
2164 2164
         } elseif ($this->aspectRatio && is_null($this->newWidth)) {
2165
-            $this->newWidth   = $this->newHeight * $this->aspectRatio;
2165
+            $this->newWidth = $this->newHeight*$this->aspectRatio;
2166 2166
             $this->log("Setting new width based on aspect ratio to {$this->newWidth}");
2167 2167
 
2168 2168
         } elseif ($this->aspectRatio && is_null($this->newHeight)) {
2169
-            $this->newHeight  = $this->newWidth / $this->aspectRatio;
2169
+            $this->newHeight = $this->newWidth/$this->aspectRatio;
2170 2170
             $this->log("Setting new height based on aspect ratio to {$this->newHeight}");
2171 2171
         }
2172 2172
 
2173 2173
         // Change width & height based on dpr
2174 2174
         if ($this->dpr != 1) {
2175 2175
             if (!is_null($this->newWidth)) {
2176
-                $this->newWidth  = round($this->newWidth * $this->dpr);
2176
+                $this->newWidth = round($this->newWidth*$this->dpr);
2177 2177
                 $this->log("Setting new width based on dpr={$this->dpr} - w={$this->newWidth}");
2178 2178
             }
2179 2179
             if (!is_null($this->newHeight)) {
2180
-                $this->newHeight = round($this->newHeight * $this->dpr);
2180
+                $this->newHeight = round($this->newHeight*$this->dpr);
2181 2181
                 $this->log("Setting new height based on dpr={$this->dpr} - h={$this->newHeight}");
2182 2182
             }
2183 2183
         }
@@ -2212,10 +2212,10 @@  discard block
 block discarded – undo
2212 2212
 
2213 2213
         // Check if there is an area to crop off
2214 2214
         if (isset($this->area)) {
2215
-            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);
2216
-            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);
2217
-            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);
2218
-            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);
2215
+            $this->offset['top']    = round($this->area['top']/100*$this->height);
2216
+            $this->offset['right']  = round($this->area['right']/100*$this->width);
2217
+            $this->offset['bottom'] = round($this->area['bottom']/100*$this->height);
2218
+            $this->offset['left']   = round($this->area['left']/100*$this->width);
2219 2219
             $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];
2220 2220
             $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];
2221 2221
             $this->width  = $this->offset['width'];
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
             } elseif ($this->crop['start_x'] == 'right') {
2238 2238
                 $this->crop['start_x'] = $this->width - $width;
2239 2239
             } elseif ($this->crop['start_x'] == 'center') {
2240
-                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);
2240
+                $this->crop['start_x'] = round($this->width/2) - round($width/2);
2241 2241
             }
2242 2242
 
2243 2243
             if ($this->crop['start_y'] == 'top') {
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
             } elseif ($this->crop['start_y'] == 'bottom') {
2246 2246
                 $this->crop['start_y'] = $this->height - $height;
2247 2247
             } elseif ($this->crop['start_y'] == 'center') {
2248
-                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);
2248
+                $this->crop['start_y'] = round($this->height/2) - round($height/2);
2249 2249
             }
2250 2250
 
2251 2251
             $this->log("Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.");
@@ -2266,25 +2266,25 @@  discard block
 block discarded – undo
2266 2266
 
2267 2267
                 // Both new width and height are set.
2268 2268
                 // Use newWidth and newHeigh as max width/height, image should not be larger.
2269
-                $ratioWidth  = $width  / $this->newWidth;
2270
-                $ratioHeight = $height / $this->newHeight;
2269
+                $ratioWidth  = $width/$this->newWidth;
2270
+                $ratioHeight = $height/$this->newHeight;
2271 2271
                 $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;
2272
-                $this->newWidth  = round($width  / $ratio);
2273
-                $this->newHeight = round($height / $ratio);
2272
+                $this->newWidth  = round($width/$ratio);
2273
+                $this->newHeight = round($height/$ratio);
2274 2274
                 $this->log("New width and height was set.");
2275 2275
 
2276 2276
             } elseif (isset($this->newWidth)) {
2277 2277
 
2278 2278
                 // Use new width as max-width
2279
-                $factor = (float)$this->newWidth / (float)$width;
2280
-                $this->newHeight = round($factor * $height);
2279
+                $factor = (float)$this->newWidth/(float)$width;
2280
+                $this->newHeight = round($factor*$height);
2281 2281
                 $this->log("New width was set.");
2282 2282
 
2283 2283
             } elseif (isset($this->newHeight)) {
2284 2284
 
2285 2285
                 // Use new height as max-hight
2286
-                $factor = (float)$this->newHeight / (float)$height;
2287
-                $this->newWidth = round($factor * $width);
2286
+                $factor = (float)$this->newHeight/(float)$height;
2287
+                $this->newWidth = round($factor*$width);
2288 2288
                 $this->log("New height was set.");
2289 2289
 
2290 2290
             } else {
@@ -2299,8 +2299,8 @@  discard block
 block discarded – undo
2299 2299
             if ($this->cropToFit || $this->fillToFit) {
2300 2300
 
2301 2301
                 // Get relations of original & target image
2302
-                $ratioWidth  = $width  / $this->newWidth;
2303
-                $ratioHeight = $height / $this->newHeight;
2302
+                $ratioWidth  = $width/$this->newWidth;
2303
+                $ratioHeight = $height/$this->newHeight;
2304 2304
 
2305 2305
                 if ($this->cropToFit) {
2306 2306
 
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
                     // image should fit the area.
2309 2309
                     $this->log("Crop to fit.");
2310 2310
                     $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;
2311
-                    $this->cropWidth  = round($width  / $ratio);
2312
-                    $this->cropHeight = round($height / $ratio);
2311
+                    $this->cropWidth  = round($width/$ratio);
2312
+                    $this->cropHeight = round($height/$ratio);
2313 2313
                     $this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
2314 2314
 
2315 2315
                 } elseif ($this->fillToFit) {
@@ -2318,8 +2318,8 @@  discard block
 block discarded – undo
2318 2318
                     // image should fit the area.
2319 2319
                     $this->log("Fill to fit.");
2320 2320
                     $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;
2321
-                    $this->fillWidth  = round($width  / $ratio);
2322
-                    $this->fillHeight = round($height / $ratio);
2321
+                    $this->fillWidth  = round($width/$ratio);
2322
+                    $this->fillHeight = round($height/$ratio);
2323 2323
                     $this->log("Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).");
2324 2324
                 }
2325 2325
             }
@@ -2501,17 +2501,17 @@  discard block
 block discarded – undo
2501 2501
     public function generateFilename($base = null, $useSubdir = true, $prefix = null)
2502 2502
     {
2503 2503
         $filename     = basename($this->pathToImage);
2504
-        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;
2505
-        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;
2506
-        $crop_x       = $this->crop_x       ? "_x{$this->crop_x}"        : null;
2507
-        $crop_y       = $this->crop_y       ? "_y{$this->crop_y}"        : null;
2508
-        $scale        = $this->scale        ? "_s{$this->scale}"         : null;
2509
-        $bgColor      = $this->bgColor      ? "_bgc{$this->bgColor}"     : null;
2510
-        $quality      = $this->quality      ? "_q{$this->quality}"       : null;
2511
-        $compress     = $this->compress     ? "_co{$this->compress}"     : null;
2504
+        $cropToFit    = $this->cropToFit ? '_cf' : null;
2505
+        $fillToFit    = $this->fillToFit ? '_ff' : null;
2506
+        $crop_x       = $this->crop_x ? "_x{$this->crop_x}" : null;
2507
+        $crop_y       = $this->crop_y ? "_y{$this->crop_y}" : null;
2508
+        $scale        = $this->scale ? "_s{$this->scale}" : null;
2509
+        $bgColor      = $this->bgColor ? "_bgc{$this->bgColor}" : null;
2510
+        $quality      = $this->quality ? "_q{$this->quality}" : null;
2511
+        $compress     = $this->compress ? "_co{$this->compress}" : null;
2512 2512
         $rotateBefore = $this->rotateBefore ? "_rb{$this->rotateBefore}" : null;
2513
-        $rotateAfter  = $this->rotateAfter  ? "_ra{$this->rotateAfter}"  : null;
2514
-        $lossy        = $this->lossy        ? "_l"                       : null;
2513
+        $rotateAfter  = $this->rotateAfter ? "_ra{$this->rotateAfter}" : null;
2514
+        $lossy        = $this->lossy ? "_l" : null;
2515 2515
 
2516 2516
         $saveAs = $this->normalizeFileExtension();
2517 2517
         $saveAs = $saveAs ? "_$saveAs" : null;
@@ -2521,7 +2521,7 @@  discard block
 block discarded – undo
2521 2521
             $copyStrat = "_rs";
2522 2522
         }
2523 2523
 
2524
-        $width  = $this->newWidth  ? '_' . $this->newWidth  : null;
2524
+        $width  = $this->newWidth ? '_' . $this->newWidth : null;
2525 2525
         $height = $this->newHeight ? '_' . $this->newHeight : null;
2526 2526
 
2527 2527
         $offset = isset($this->offset)
@@ -2537,23 +2537,23 @@  discard block
 block discarded – undo
2537 2537
             foreach ($this->filters as $filter) {
2538 2538
                 if (is_array($filter)) {
2539 2539
                     $filters .= "_f{$filter['id']}";
2540
-                    for ($i=1; $i<=$filter['argc']; $i++) {
2541
-                        $filters .= "-".$filter["arg{$i}"];
2540
+                    for ($i = 1; $i <= $filter['argc']; $i++) {
2541
+                        $filters .= "-" . $filter["arg{$i}"];
2542 2542
                     }
2543 2543
                 }
2544 2544
             }
2545 2545
         }
2546 2546
 
2547 2547
         $sharpen = $this->sharpen ? 's' : null;
2548
-        $emboss  = $this->emboss  ? 'e' : null;
2549
-        $blur    = $this->blur    ? 'b' : null;
2548
+        $emboss  = $this->emboss ? 'e' : null;
2549
+        $blur    = $this->blur ? 'b' : null;
2550 2550
         $palette = $this->palette ? 'p' : null;
2551 2551
 
2552 2552
         $autoRotate = $this->autoRotate ? 'ar' : null;
2553 2553
 
2554 2554
         $optimize  = $this->jpegOptimize ? 'o' : null;
2555
-        $optimize .= $this->pngFilter    ? 'f' : null;
2556
-        $optimize .= $this->pngDeflate   ? 'd' : null;
2555
+        $optimize .= $this->pngFilter ? 'f' : null;
2556
+        $optimize .= $this->pngDeflate ? 'd' : null;
2557 2557
 
2558 2558
         $convolve = null;
2559 2559
         if ($this->convolve) {
@@ -2767,9 +2767,9 @@  discard block
 block discarded – undo
2767 2767
             $h = imagesy($im);
2768 2768
             $w = imagesx($im);
2769 2769
             $c = array();
2770
-            for ($x=0; $x < $w; $x++) {
2771
-                for ($y=0; $y < $h; $y++) {
2772
-                    @$c['c'.imagecolorat($im, $x, $y)]++;
2770
+            for ($x = 0; $x < $w; $x++) {
2771
+                for ($y = 0; $y < $h; $y++) {
2772
+                    @$c['c' . imagecolorat($im, $x, $y)]++;
2773 2773
                 }
2774 2774
             }
2775 2775
             return count($c);
@@ -2807,8 +2807,8 @@  discard block
 block discarded – undo
2807 2807
         // Scale the original image before starting
2808 2808
         if (isset($this->scale)) {
2809 2809
             $this->log("Scale by {$this->scale}%");
2810
-            $newWidth  = $this->width * $this->scale / 100;
2811
-            $newHeight = $this->height * $this->scale / 100;
2810
+            $newWidth  = $this->width*$this->scale/100;
2811
+            $newHeight = $this->height*$this->scale/100;
2812 2812
             $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);
2813 2813
             imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);
2814 2814
             $this->image = $img;
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
      */
2844 2844
     public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
2845 2845
     {
2846
-        if($this->copyStrategy == self::RESIZE) {
2846
+        if ($this->copyStrategy == self::RESIZE) {
2847 2847
             $this->log("Copy by resize");
2848 2848
             imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
2849 2849
         } else {
@@ -2908,14 +2908,14 @@  discard block
 block discarded – undo
2908 2908
                 $cropY = 0;
2909 2909
 
2910 2910
                 if ($this->newWidth > $this->width) {
2911
-                    $posX = round(($this->newWidth - $this->width) / 2);
2911
+                    $posX = round(($this->newWidth - $this->width)/2);
2912 2912
                 }
2913 2913
                 if ($this->newWidth < $this->width) {
2914 2914
                     $cropX = round(($this->width/2) - ($this->newWidth/2));
2915 2915
                 }
2916 2916
 
2917 2917
                 if ($this->newHeight > $this->height) {
2918
-                    $posY = round(($this->newHeight - $this->height) / 2);
2918
+                    $posY = round(($this->newHeight - $this->height)/2);
2919 2919
                 }
2920 2920
                 if ($this->newHeight < $this->height) {
2921 2921
                     $cropY = round(($this->height/2) - ($this->newHeight/2));
@@ -2954,14 +2954,14 @@  discard block
 block discarded – undo
2954 2954
             $posX = 0;
2955 2955
             $posY = 0;
2956 2956
 
2957
-            $ratioOrig = $this->width / $this->height;
2958
-            $ratioNew  = $this->newWidth / $this->newHeight;
2957
+            $ratioOrig = $this->width/$this->height;
2958
+            $ratioNew  = $this->newWidth/$this->newHeight;
2959 2959
 
2960 2960
             // Check ratio for landscape or portrait
2961 2961
             if ($ratioOrig < $ratioNew) {
2962
-                $posX = round(($this->newWidth - $this->fillWidth) / 2);
2962
+                $posX = round(($this->newWidth - $this->fillWidth)/2);
2963 2963
             } else {
2964
-                $posY = round(($this->newHeight - $this->fillHeight) / 2);
2964
+                $posY = round(($this->newHeight - $this->fillHeight)/2);
2965 2965
             }
2966 2966
 
2967 2967
             if (!$this->upscale
@@ -2969,8 +2969,8 @@  discard block
 block discarded – undo
2969 2969
             ) {
2970 2970
 
2971 2971
                 $this->log("Resizing - smaller image, do not upscale.");
2972
-                $posX = round(($this->newWidth - $this->width) / 2);
2973
-                $posY = round(($this->newHeight - $this->height) / 2);
2972
+                $posX = round(($this->newWidth - $this->width)/2);
2973
+                $posY = round(($this->newHeight - $this->height)/2);
2974 2974
                 $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
2975 2975
                 imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
2976 2976
 
@@ -3004,14 +3004,14 @@  discard block
 block discarded – undo
3004 3004
                     $cropY = 0;
3005 3005
 
3006 3006
                     if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
3007
-                        $posX = round(($this->newWidth - $this->width) / 2);
3008
-                        $posY = round(($this->newHeight - $this->height) / 2);
3007
+                        $posX = round(($this->newWidth - $this->width)/2);
3008
+                        $posY = round(($this->newHeight - $this->height)/2);
3009 3009
                     } elseif ($this->newWidth > $this->width) {
3010
-                        $posX = round(($this->newWidth - $this->width) / 2);
3011
-                        $cropY = round(($this->height - $this->newHeight) / 2);
3010
+                        $posX = round(($this->newWidth - $this->width)/2);
3011
+                        $cropY = round(($this->height - $this->newHeight)/2);
3012 3012
                     } elseif ($this->newHeight > $this->height) {
3013
-                        $posY = round(($this->newHeight - $this->height) / 2);
3014
-                        $cropX = round(($this->width - $this->newWidth) / 2);
3013
+                        $posY = round(($this->newHeight - $this->height)/2);
3014
+                        $cropX = round(($this->width - $this->newWidth)/2);
3015 3015
                     }
3016 3016
 
3017 3017
                     $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
@@ -3274,7 +3274,7 @@  discard block
 block discarded – undo
3274 3274
             );
3275 3275
         }
3276 3276
 
3277
-        array_walk($part, function ($item, $key) {
3277
+        array_walk($part, function($item, $key) {
3278 3278
             if (!is_numeric($item)) {
3279 3279
                 throw new Exception("Argument to convolve expression should be float but is not.");
3280 3280
             }
@@ -3546,7 +3546,7 @@  discard block
 block discarded – undo
3546 3546
 
3547 3547
         $type = $this->getTargetImageExtension();
3548 3548
         $this->Log("Saving image as " . $type);
3549
-        switch($type) {
3549
+        switch ($type) {
3550 3550
 
3551 3551
             case 'jpeg':
3552 3552
             case 'jpg':
@@ -3898,16 +3898,16 @@  discard block
 block discarded – undo
3898 3898
         $details['mimeType']    = $this->getMimeType($this->fileType);
3899 3899
         $details['width']       = $this->width;
3900 3900
         $details['height']      = $this->height;
3901
-        $details['aspectRatio'] = round($this->width / $this->height, 3);
3901
+        $details['aspectRatio'] = round($this->width/$this->height, 3);
3902 3902
         $details['size']        = filesize($file);
3903 3903
         $details['colors'] = $this->colorsTotal($this->image);
3904 3904
         $details['includedFiles'] = count(get_included_files());
3905
-        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ;
3905
+        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB";
3906 3906
         $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB";
3907 3907
         $details['memoryLimit'] = ini_get('memory_limit');
3908 3908
 
3909 3909
         if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
3910
-            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
3910
+            $details['loadTime'] = (string)round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
3911 3911
         }
3912 3912
 
3913 3913
         if ($details['mimeType'] == 'image/png') {
@@ -3999,7 +3999,7 @@  discard block
 block discarded – undo
3999 3999
         $log = null;
4000 4000
         $this->log("### Summary of verbose log");
4001 4001
         $this->log("As JSON: \n" . $this->json());
4002
-        $this->log("Memory peak: " . round(memory_get_peak_usage() /1024/1024) . "M");
4002
+        $this->log("Memory peak: " . round(memory_get_peak_usage()/1024/1024) . "M");
4003 4003
         $this->log("Memory limit: " . ini_get('memory_limit'));
4004 4004
 
4005 4005
         $included = get_included_files();
@@ -4407,7 +4407,7 @@  discard block
 block discarded – undo
4407 4407
 /**
4408 4408
  * Custom exception handler.
4409 4409
  */
4410
-set_exception_handler(function ($exception) {
4410
+set_exception_handler(function($exception) {
4411 4411
     errorPage(
4412 4412
         "<p><b>img.php: Uncaught exception:</b> <p>"
4413 4413
         . $exception->getMessage()
@@ -4424,7 +4424,7 @@  discard block
 block discarded – undo
4424 4424
  * Get configuration options from file, if the file exists, else use $config
4425 4425
  * if its defined or create an empty $config.
4426 4426
  */
4427
-$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
4427
+$configFile = __DIR__ . '/' . basename(__FILE__, '.php') . '_config.php';
4428 4428
 
4429 4429
 if (is_file($configFile)) {
4430 4430
     $config = require $configFile;
@@ -4800,7 +4800,7 @@  discard block
 block discarded – undo
4800 4800
  * Manage size constants from config file, use constants to replace values
4801 4801
  * for width and height.
4802 4802
  */
4803
-$sizeConstant = getConfig('size_constant', function () {
4803
+$sizeConstant = getConfig('size_constant', function() {
4804 4804
 
4805 4805
     // Set sizes to map constant to value, easier to use with width or height
4806 4806
     $sizes = array(
@@ -4814,7 +4814,7 @@  discard block
 block discarded – undo
4814 4814
     $gridColumns     = 24;
4815 4815
 
4816 4816
     for ($i = 1; $i <= $gridColumns; $i++) {
4817
-        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
4817
+        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth)*$i - $gridGutterWidth;
4818 4818
     }
4819 4819
 
4820 4820
     return $sizes;
@@ -4836,7 +4836,7 @@  discard block
 block discarded – undo
4836 4836
 }
4837 4837
 
4838 4838
 // Support width as % of original width
4839
-if ($newWidth && $newWidth[strlen($newWidth)-1] == '%') {
4839
+if ($newWidth && $newWidth[strlen($newWidth) - 1] == '%') {
4840 4840
     is_numeric(substr($newWidth, 0, -1))
4841 4841
         or errorPage('Width % not numeric.', 404);
4842 4842
 } else {
@@ -4861,7 +4861,7 @@  discard block
 block discarded – undo
4861 4861
 }
4862 4862
 
4863 4863
 // height
4864
-if ($newHeight && $newHeight[strlen($newHeight)-1] == '%') {
4864
+if ($newHeight && $newHeight[strlen($newHeight) - 1] == '%') {
4865 4865
     is_numeric(substr($newHeight, 0, -1))
4866 4866
         or errorPage('Height % out of range.', 404);
4867 4867
 } else {
@@ -4878,7 +4878,7 @@  discard block
 block discarded – undo
4878 4878
  * aspect-ratio, ar - affecting the resulting image width, height and resize options
4879 4879
  */
4880 4880
 $aspectRatio         = get(array('aspect-ratio', 'ar'));
4881
-$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {
4881
+$aspectRatioConstant = getConfig('aspect_ratio_constant', function() {
4882 4882
     return array(
4883 4883
         '3:1'    => 3/1,
4884 4884
         '3:2'    => 3/2,
@@ -4900,7 +4900,7 @@  discard block
 block discarded – undo
4900 4900
 }
4901 4901
 
4902 4902
 if ($negateAspectRatio) {
4903
-    $aspectRatio = 1 / $aspectRatio;
4903
+    $aspectRatio = 1/$aspectRatio;
4904 4904
 }
4905 4905
 
4906 4906
 is_null($aspectRatio)
@@ -4964,7 +4964,7 @@  discard block
 block discarded – undo
4964 4964
 if ($fillToFit !== null) {
4965 4965
 
4966 4966
     if (!empty($fillToFit)) {
4967
-        $bgColor   = $fillToFit;
4967
+        $bgColor = $fillToFit;
4968 4968
         verbose("fillToFit changed bgColor to = $bgColor");
4969 4969
     }
4970 4970
 
Please login to merge, or discard this patch.
a/vendor/mos/cimage/webroot/imgd.php 2 patches
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 $config = array(
28 28
 
29
-    'mode'         => 'development',               // 'production', 'development', 'strict'
29
+    'mode'         => 'development', // 'production', 'development', 'strict'
30 30
     //'image_path'   =>  __DIR__ . '/img/',
31 31
     //'cache_path'   =>  __DIR__ . '/../cache/',
32 32
     //'alias_path'   =>  __DIR__ . '/img/alias/',
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         $url .= $parts['host'];
264 264
         $url .= isset($parts['port'])
265 265
             ? ":" . $parts['port']
266
-            : "" ;
266
+            : "";
267 267
         $url .= $parts['path'];
268 268
 
269 269
         return $url;
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     public function getStatus()
410 410
     {
411 411
         return isset($this->response['header']['status'])
412
-            ? (int) $this->response['header']['status']
412
+            ? (int)$this->response['header']['status']
413 413
             : null;
414 414
     }
415 415
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
             // max-age=2592000
485 485
             $part = explode('=', $cacheControl);
486 486
             $maxAge = ($part[0] == "max-age")
487
-                ? (int) $part[1]
487
+                ? (int)$part[1]
488 488
                 : null;
489 489
         }
490 490
 
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
             $cimageVersion = CIMAGE_USER_AGENT;
668 668
         }
669 669
         
670
-        $this->http->setHeader("User-Agent", "$cimageVersion (PHP/". phpversion() . " cURL)");
670
+        $this->http->setHeader("User-Agent", "$cimageVersion (PHP/" . phpversion() . " cURL)");
671 671
         $this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
672 672
 
673 673
         if ($this->useCache) {
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
 
1013 1013
         $ascii = null;
1014 1014
         $incY = $this->scale;
1015
-        $incX = $this->scale / 2;
1015
+        $incX = $this->scale/2;
1016 1016
         
1017 1017
         for ($y = 0; $y < $height - 1; $y += $incY) {
1018 1018
             for ($x = 0; $x < $width - 1; $x += $incX) {
1019
-                $toX = min($x + $this->scale / 2, $width - 1);
1019
+                $toX = min($x + $this->scale/2, $width - 1);
1020 1020
                 $toY = min($y + $this->scale, $height - 1);
1021 1021
                 $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);
1022 1022
                 $ascii .= $this->luminance2character($luminance);
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
      */
1043 1043
     public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)
1044 1044
     {
1045
-        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);
1045
+        $numPixels = ($x2 - $x1 + 1)*($y2 - $y1 + 1);
1046 1046
         $luminance = 0;
1047 1047
         
1048 1048
         for ($x = $x1; $x <= $x2; $x++) {
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
             }
1056 1056
         }
1057 1057
         
1058
-        return $luminance / $numPixels;
1058
+        return $luminance/$numPixels;
1059 1059
     }
1060 1060
 
1061 1061
 
@@ -1073,17 +1073,17 @@  discard block
 block discarded – undo
1073 1073
     {
1074 1074
         switch ($this->luminanceStrategy) {
1075 1075
             case 1:
1076
-                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
1076
+                $luminance = ($red*0.2126 + $green*0.7152 + $blue*0.0722)/255;
1077 1077
                 break;
1078 1078
             case 2:
1079
-                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;
1079
+                $luminance = ($red*0.299 + $green*0.587 + $blue*0.114)/255;
1080 1080
                 break;
1081 1081
             case 3:
1082
-                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;
1082
+                $luminance = sqrt(0.299*pow($red, 2) + 0.587*pow($green, 2) + 0.114*pow($blue, 2))/255;
1083 1083
                 break;
1084 1084
             case 0:
1085 1085
             default:
1086
-                $luminance = ($red + $green + $blue) / (255 * 3);
1086
+                $luminance = ($red + $green + $blue)/(255*3);
1087 1087
         }
1088 1088
 
1089 1089
         return $luminance;
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
      */
1102 1102
     public function luminance2character($luminance)
1103 1103
     {
1104
-        $position = (int) round($luminance * ($this->charCount - 1));
1104
+        $position = (int)round($luminance*($this->charCount - 1));
1105 1105
         $char = $this->characters[$position];
1106 1106
         return $char;
1107 1107
     }
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
     /**
1342 1342
      * Image dimensions, calculated from loaded image.
1343 1343
      */
1344
-    private $width;  // Calculated from source image
1344
+    private $width; // Calculated from source image
1345 1345
     private $height; // Calculated from source image
1346 1346
 
1347 1347
 
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
      * New image dimensions, incoming as argument or calculated.
1350 1350
      */
1351 1351
     private $newWidth;
1352
-    private $newWidthOrig;  // Save original value
1352
+    private $newWidthOrig; // Save original value
1353 1353
     private $newHeight;
1354 1354
     private $newHeightOrig; // Save original value
1355 1355
 
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
      */
1656 1656
     public function createDummyImage($width = null, $height = null)
1657 1657
     {
1658
-        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;
1658
+        $this->newWidth  = $this->newWidth ?: $width ?: 100;
1659 1659
         $this->newHeight = $this->newHeight ?: $height ?: 100;
1660 1660
 
1661 1661
         $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
                 $parts = explode(',', $filterStr);
1986 1986
                 $filter = $this->mapFilter($parts[0]);
1987 1987
                 $filter['str'] = $filterStr;
1988
-                for ($i=1; $i<=$filter['argc']; $i++) {
1988
+                for ($i = 1; $i <= $filter['argc']; $i++) {
1989 1989
                     if (isset($parts[$i])) {
1990 1990
                         $filter["arg{$i}"] = $parts[$i];
1991 1991
                     } else {
@@ -2031,16 +2031,16 @@  discard block
 block discarded – undo
2031 2031
     private function mapFilter($name)
2032 2032
     {
2033 2033
         $map = array(
2034
-            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),
2035
-            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),
2036
-            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),
2037
-            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),
2038
-            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),
2039
-            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),
2040
-            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),
2041
-            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),
2042
-            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),
2043
-            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),
2034
+            'negate'          => array('id'=>0, 'argc'=>0, 'type'=>IMG_FILTER_NEGATE),
2035
+            'grayscale'       => array('id'=>1, 'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),
2036
+            'brightness'      => array('id'=>2, 'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),
2037
+            'contrast'        => array('id'=>3, 'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),
2038
+            'colorize'        => array('id'=>4, 'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),
2039
+            'edgedetect'      => array('id'=>5, 'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),
2040
+            'emboss'          => array('id'=>6, 'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),
2041
+            'gaussian_blur'   => array('id'=>7, 'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),
2042
+            'selective_blur'  => array('id'=>8, 'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),
2043
+            'mean_removal'    => array('id'=>9, 'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),
2044 2044
             'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),
2045 2045
             'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),
2046 2046
         );
@@ -2134,15 +2134,15 @@  discard block
 block discarded – undo
2134 2134
 
2135 2135
         // width as %
2136 2136
         if ($this->newWidth
2137
-            && $this->newWidth[strlen($this->newWidth)-1] == '%') {
2138
-            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;
2137
+            && $this->newWidth[strlen($this->newWidth) - 1] == '%') {
2138
+            $this->newWidth = $this->width*substr($this->newWidth, 0, -1)/100;
2139 2139
             $this->log("Setting new width based on % to {$this->newWidth}");
2140 2140
         }
2141 2141
 
2142 2142
         // height as %
2143 2143
         if ($this->newHeight
2144
-            && $this->newHeight[strlen($this->newHeight)-1] == '%') {
2145
-            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;
2144
+            && $this->newHeight[strlen($this->newHeight) - 1] == '%') {
2145
+            $this->newHeight = $this->height*substr($this->newHeight, 0, -1)/100;
2146 2146
             $this->log("Setting new height based on % to {$this->newHeight}");
2147 2147
         }
2148 2148
 
@@ -2152,32 +2152,32 @@  discard block
 block discarded – undo
2152 2152
         if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {
2153 2153
             if ($this->aspectRatio >= 1) {
2154 2154
                 $this->newWidth   = $this->width;
2155
-                $this->newHeight  = $this->width / $this->aspectRatio;
2155
+                $this->newHeight  = $this->width/$this->aspectRatio;
2156 2156
                 $this->log("Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}");
2157 2157
 
2158 2158
             } else {
2159 2159
                 $this->newHeight  = $this->height;
2160
-                $this->newWidth   = $this->height * $this->aspectRatio;
2160
+                $this->newWidth   = $this->height*$this->aspectRatio;
2161 2161
                 $this->log("Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}");
2162 2162
             }
2163 2163
 
2164 2164
         } elseif ($this->aspectRatio && is_null($this->newWidth)) {
2165
-            $this->newWidth   = $this->newHeight * $this->aspectRatio;
2165
+            $this->newWidth = $this->newHeight*$this->aspectRatio;
2166 2166
             $this->log("Setting new width based on aspect ratio to {$this->newWidth}");
2167 2167
 
2168 2168
         } elseif ($this->aspectRatio && is_null($this->newHeight)) {
2169
-            $this->newHeight  = $this->newWidth / $this->aspectRatio;
2169
+            $this->newHeight = $this->newWidth/$this->aspectRatio;
2170 2170
             $this->log("Setting new height based on aspect ratio to {$this->newHeight}");
2171 2171
         }
2172 2172
 
2173 2173
         // Change width & height based on dpr
2174 2174
         if ($this->dpr != 1) {
2175 2175
             if (!is_null($this->newWidth)) {
2176
-                $this->newWidth  = round($this->newWidth * $this->dpr);
2176
+                $this->newWidth = round($this->newWidth*$this->dpr);
2177 2177
                 $this->log("Setting new width based on dpr={$this->dpr} - w={$this->newWidth}");
2178 2178
             }
2179 2179
             if (!is_null($this->newHeight)) {
2180
-                $this->newHeight = round($this->newHeight * $this->dpr);
2180
+                $this->newHeight = round($this->newHeight*$this->dpr);
2181 2181
                 $this->log("Setting new height based on dpr={$this->dpr} - h={$this->newHeight}");
2182 2182
             }
2183 2183
         }
@@ -2212,10 +2212,10 @@  discard block
 block discarded – undo
2212 2212
 
2213 2213
         // Check if there is an area to crop off
2214 2214
         if (isset($this->area)) {
2215
-            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);
2216
-            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);
2217
-            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);
2218
-            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);
2215
+            $this->offset['top']    = round($this->area['top']/100*$this->height);
2216
+            $this->offset['right']  = round($this->area['right']/100*$this->width);
2217
+            $this->offset['bottom'] = round($this->area['bottom']/100*$this->height);
2218
+            $this->offset['left']   = round($this->area['left']/100*$this->width);
2219 2219
             $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];
2220 2220
             $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];
2221 2221
             $this->width  = $this->offset['width'];
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
             } elseif ($this->crop['start_x'] == 'right') {
2238 2238
                 $this->crop['start_x'] = $this->width - $width;
2239 2239
             } elseif ($this->crop['start_x'] == 'center') {
2240
-                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);
2240
+                $this->crop['start_x'] = round($this->width/2) - round($width/2);
2241 2241
             }
2242 2242
 
2243 2243
             if ($this->crop['start_y'] == 'top') {
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
             } elseif ($this->crop['start_y'] == 'bottom') {
2246 2246
                 $this->crop['start_y'] = $this->height - $height;
2247 2247
             } elseif ($this->crop['start_y'] == 'center') {
2248
-                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);
2248
+                $this->crop['start_y'] = round($this->height/2) - round($height/2);
2249 2249
             }
2250 2250
 
2251 2251
             $this->log("Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.");
@@ -2266,25 +2266,25 @@  discard block
 block discarded – undo
2266 2266
 
2267 2267
                 // Both new width and height are set.
2268 2268
                 // Use newWidth and newHeigh as max width/height, image should not be larger.
2269
-                $ratioWidth  = $width  / $this->newWidth;
2270
-                $ratioHeight = $height / $this->newHeight;
2269
+                $ratioWidth  = $width/$this->newWidth;
2270
+                $ratioHeight = $height/$this->newHeight;
2271 2271
                 $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;
2272
-                $this->newWidth  = round($width  / $ratio);
2273
-                $this->newHeight = round($height / $ratio);
2272
+                $this->newWidth  = round($width/$ratio);
2273
+                $this->newHeight = round($height/$ratio);
2274 2274
                 $this->log("New width and height was set.");
2275 2275
 
2276 2276
             } elseif (isset($this->newWidth)) {
2277 2277
 
2278 2278
                 // Use new width as max-width
2279
-                $factor = (float)$this->newWidth / (float)$width;
2280
-                $this->newHeight = round($factor * $height);
2279
+                $factor = (float)$this->newWidth/(float)$width;
2280
+                $this->newHeight = round($factor*$height);
2281 2281
                 $this->log("New width was set.");
2282 2282
 
2283 2283
             } elseif (isset($this->newHeight)) {
2284 2284
 
2285 2285
                 // Use new height as max-hight
2286
-                $factor = (float)$this->newHeight / (float)$height;
2287
-                $this->newWidth = round($factor * $width);
2286
+                $factor = (float)$this->newHeight/(float)$height;
2287
+                $this->newWidth = round($factor*$width);
2288 2288
                 $this->log("New height was set.");
2289 2289
 
2290 2290
             } else {
@@ -2299,8 +2299,8 @@  discard block
 block discarded – undo
2299 2299
             if ($this->cropToFit || $this->fillToFit) {
2300 2300
 
2301 2301
                 // Get relations of original & target image
2302
-                $ratioWidth  = $width  / $this->newWidth;
2303
-                $ratioHeight = $height / $this->newHeight;
2302
+                $ratioWidth  = $width/$this->newWidth;
2303
+                $ratioHeight = $height/$this->newHeight;
2304 2304
 
2305 2305
                 if ($this->cropToFit) {
2306 2306
 
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
                     // image should fit the area.
2309 2309
                     $this->log("Crop to fit.");
2310 2310
                     $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;
2311
-                    $this->cropWidth  = round($width  / $ratio);
2312
-                    $this->cropHeight = round($height / $ratio);
2311
+                    $this->cropWidth  = round($width/$ratio);
2312
+                    $this->cropHeight = round($height/$ratio);
2313 2313
                     $this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
2314 2314
 
2315 2315
                 } elseif ($this->fillToFit) {
@@ -2318,8 +2318,8 @@  discard block
 block discarded – undo
2318 2318
                     // image should fit the area.
2319 2319
                     $this->log("Fill to fit.");
2320 2320
                     $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;
2321
-                    $this->fillWidth  = round($width  / $ratio);
2322
-                    $this->fillHeight = round($height / $ratio);
2321
+                    $this->fillWidth  = round($width/$ratio);
2322
+                    $this->fillHeight = round($height/$ratio);
2323 2323
                     $this->log("Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).");
2324 2324
                 }
2325 2325
             }
@@ -2501,17 +2501,17 @@  discard block
 block discarded – undo
2501 2501
     public function generateFilename($base = null, $useSubdir = true, $prefix = null)
2502 2502
     {
2503 2503
         $filename     = basename($this->pathToImage);
2504
-        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;
2505
-        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;
2506
-        $crop_x       = $this->crop_x       ? "_x{$this->crop_x}"        : null;
2507
-        $crop_y       = $this->crop_y       ? "_y{$this->crop_y}"        : null;
2508
-        $scale        = $this->scale        ? "_s{$this->scale}"         : null;
2509
-        $bgColor      = $this->bgColor      ? "_bgc{$this->bgColor}"     : null;
2510
-        $quality      = $this->quality      ? "_q{$this->quality}"       : null;
2511
-        $compress     = $this->compress     ? "_co{$this->compress}"     : null;
2504
+        $cropToFit    = $this->cropToFit ? '_cf' : null;
2505
+        $fillToFit    = $this->fillToFit ? '_ff' : null;
2506
+        $crop_x       = $this->crop_x ? "_x{$this->crop_x}" : null;
2507
+        $crop_y       = $this->crop_y ? "_y{$this->crop_y}" : null;
2508
+        $scale        = $this->scale ? "_s{$this->scale}" : null;
2509
+        $bgColor      = $this->bgColor ? "_bgc{$this->bgColor}" : null;
2510
+        $quality      = $this->quality ? "_q{$this->quality}" : null;
2511
+        $compress     = $this->compress ? "_co{$this->compress}" : null;
2512 2512
         $rotateBefore = $this->rotateBefore ? "_rb{$this->rotateBefore}" : null;
2513
-        $rotateAfter  = $this->rotateAfter  ? "_ra{$this->rotateAfter}"  : null;
2514
-        $lossy        = $this->lossy        ? "_l"                       : null;
2513
+        $rotateAfter  = $this->rotateAfter ? "_ra{$this->rotateAfter}" : null;
2514
+        $lossy        = $this->lossy ? "_l" : null;
2515 2515
 
2516 2516
         $saveAs = $this->normalizeFileExtension();
2517 2517
         $saveAs = $saveAs ? "_$saveAs" : null;
@@ -2521,7 +2521,7 @@  discard block
 block discarded – undo
2521 2521
             $copyStrat = "_rs";
2522 2522
         }
2523 2523
 
2524
-        $width  = $this->newWidth  ? '_' . $this->newWidth  : null;
2524
+        $width  = $this->newWidth ? '_' . $this->newWidth : null;
2525 2525
         $height = $this->newHeight ? '_' . $this->newHeight : null;
2526 2526
 
2527 2527
         $offset = isset($this->offset)
@@ -2537,23 +2537,23 @@  discard block
 block discarded – undo
2537 2537
             foreach ($this->filters as $filter) {
2538 2538
                 if (is_array($filter)) {
2539 2539
                     $filters .= "_f{$filter['id']}";
2540
-                    for ($i=1; $i<=$filter['argc']; $i++) {
2541
-                        $filters .= "-".$filter["arg{$i}"];
2540
+                    for ($i = 1; $i <= $filter['argc']; $i++) {
2541
+                        $filters .= "-" . $filter["arg{$i}"];
2542 2542
                     }
2543 2543
                 }
2544 2544
             }
2545 2545
         }
2546 2546
 
2547 2547
         $sharpen = $this->sharpen ? 's' : null;
2548
-        $emboss  = $this->emboss  ? 'e' : null;
2549
-        $blur    = $this->blur    ? 'b' : null;
2548
+        $emboss  = $this->emboss ? 'e' : null;
2549
+        $blur    = $this->blur ? 'b' : null;
2550 2550
         $palette = $this->palette ? 'p' : null;
2551 2551
 
2552 2552
         $autoRotate = $this->autoRotate ? 'ar' : null;
2553 2553
 
2554 2554
         $optimize  = $this->jpegOptimize ? 'o' : null;
2555
-        $optimize .= $this->pngFilter    ? 'f' : null;
2556
-        $optimize .= $this->pngDeflate   ? 'd' : null;
2555
+        $optimize .= $this->pngFilter ? 'f' : null;
2556
+        $optimize .= $this->pngDeflate ? 'd' : null;
2557 2557
 
2558 2558
         $convolve = null;
2559 2559
         if ($this->convolve) {
@@ -2767,9 +2767,9 @@  discard block
 block discarded – undo
2767 2767
             $h = imagesy($im);
2768 2768
             $w = imagesx($im);
2769 2769
             $c = array();
2770
-            for ($x=0; $x < $w; $x++) {
2771
-                for ($y=0; $y < $h; $y++) {
2772
-                    @$c['c'.imagecolorat($im, $x, $y)]++;
2770
+            for ($x = 0; $x < $w; $x++) {
2771
+                for ($y = 0; $y < $h; $y++) {
2772
+                    @$c['c' . imagecolorat($im, $x, $y)]++;
2773 2773
                 }
2774 2774
             }
2775 2775
             return count($c);
@@ -2807,8 +2807,8 @@  discard block
 block discarded – undo
2807 2807
         // Scale the original image before starting
2808 2808
         if (isset($this->scale)) {
2809 2809
             $this->log("Scale by {$this->scale}%");
2810
-            $newWidth  = $this->width * $this->scale / 100;
2811
-            $newHeight = $this->height * $this->scale / 100;
2810
+            $newWidth  = $this->width*$this->scale/100;
2811
+            $newHeight = $this->height*$this->scale/100;
2812 2812
             $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);
2813 2813
             imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);
2814 2814
             $this->image = $img;
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
      */
2844 2844
     public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
2845 2845
     {
2846
-        if($this->copyStrategy == self::RESIZE) {
2846
+        if ($this->copyStrategy == self::RESIZE) {
2847 2847
             $this->log("Copy by resize");
2848 2848
             imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
2849 2849
         } else {
@@ -2908,14 +2908,14 @@  discard block
 block discarded – undo
2908 2908
                 $cropY = 0;
2909 2909
 
2910 2910
                 if ($this->newWidth > $this->width) {
2911
-                    $posX = round(($this->newWidth - $this->width) / 2);
2911
+                    $posX = round(($this->newWidth - $this->width)/2);
2912 2912
                 }
2913 2913
                 if ($this->newWidth < $this->width) {
2914 2914
                     $cropX = round(($this->width/2) - ($this->newWidth/2));
2915 2915
                 }
2916 2916
 
2917 2917
                 if ($this->newHeight > $this->height) {
2918
-                    $posY = round(($this->newHeight - $this->height) / 2);
2918
+                    $posY = round(($this->newHeight - $this->height)/2);
2919 2919
                 }
2920 2920
                 if ($this->newHeight < $this->height) {
2921 2921
                     $cropY = round(($this->height/2) - ($this->newHeight/2));
@@ -2954,14 +2954,14 @@  discard block
 block discarded – undo
2954 2954
             $posX = 0;
2955 2955
             $posY = 0;
2956 2956
 
2957
-            $ratioOrig = $this->width / $this->height;
2958
-            $ratioNew  = $this->newWidth / $this->newHeight;
2957
+            $ratioOrig = $this->width/$this->height;
2958
+            $ratioNew  = $this->newWidth/$this->newHeight;
2959 2959
 
2960 2960
             // Check ratio for landscape or portrait
2961 2961
             if ($ratioOrig < $ratioNew) {
2962
-                $posX = round(($this->newWidth - $this->fillWidth) / 2);
2962
+                $posX = round(($this->newWidth - $this->fillWidth)/2);
2963 2963
             } else {
2964
-                $posY = round(($this->newHeight - $this->fillHeight) / 2);
2964
+                $posY = round(($this->newHeight - $this->fillHeight)/2);
2965 2965
             }
2966 2966
 
2967 2967
             if (!$this->upscale
@@ -2969,8 +2969,8 @@  discard block
 block discarded – undo
2969 2969
             ) {
2970 2970
 
2971 2971
                 $this->log("Resizing - smaller image, do not upscale.");
2972
-                $posX = round(($this->newWidth - $this->width) / 2);
2973
-                $posY = round(($this->newHeight - $this->height) / 2);
2972
+                $posX = round(($this->newWidth - $this->width)/2);
2973
+                $posY = round(($this->newHeight - $this->height)/2);
2974 2974
                 $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
2975 2975
                 imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
2976 2976
 
@@ -3004,14 +3004,14 @@  discard block
 block discarded – undo
3004 3004
                     $cropY = 0;
3005 3005
 
3006 3006
                     if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
3007
-                        $posX = round(($this->newWidth - $this->width) / 2);
3008
-                        $posY = round(($this->newHeight - $this->height) / 2);
3007
+                        $posX = round(($this->newWidth - $this->width)/2);
3008
+                        $posY = round(($this->newHeight - $this->height)/2);
3009 3009
                     } elseif ($this->newWidth > $this->width) {
3010
-                        $posX = round(($this->newWidth - $this->width) / 2);
3011
-                        $cropY = round(($this->height - $this->newHeight) / 2);
3010
+                        $posX = round(($this->newWidth - $this->width)/2);
3011
+                        $cropY = round(($this->height - $this->newHeight)/2);
3012 3012
                     } elseif ($this->newHeight > $this->height) {
3013
-                        $posY = round(($this->newHeight - $this->height) / 2);
3014
-                        $cropX = round(($this->width - $this->newWidth) / 2);
3013
+                        $posY = round(($this->newHeight - $this->height)/2);
3014
+                        $cropX = round(($this->width - $this->newWidth)/2);
3015 3015
                     }
3016 3016
 
3017 3017
                     $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
@@ -3274,7 +3274,7 @@  discard block
 block discarded – undo
3274 3274
             );
3275 3275
         }
3276 3276
 
3277
-        array_walk($part, function ($item, $key) {
3277
+        array_walk($part, function($item, $key) {
3278 3278
             if (!is_numeric($item)) {
3279 3279
                 throw new Exception("Argument to convolve expression should be float but is not.");
3280 3280
             }
@@ -3546,7 +3546,7 @@  discard block
 block discarded – undo
3546 3546
 
3547 3547
         $type = $this->getTargetImageExtension();
3548 3548
         $this->Log("Saving image as " . $type);
3549
-        switch($type) {
3549
+        switch ($type) {
3550 3550
 
3551 3551
             case 'jpeg':
3552 3552
             case 'jpg':
@@ -3898,16 +3898,16 @@  discard block
 block discarded – undo
3898 3898
         $details['mimeType']    = $this->getMimeType($this->fileType);
3899 3899
         $details['width']       = $this->width;
3900 3900
         $details['height']      = $this->height;
3901
-        $details['aspectRatio'] = round($this->width / $this->height, 3);
3901
+        $details['aspectRatio'] = round($this->width/$this->height, 3);
3902 3902
         $details['size']        = filesize($file);
3903 3903
         $details['colors'] = $this->colorsTotal($this->image);
3904 3904
         $details['includedFiles'] = count(get_included_files());
3905
-        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ;
3905
+        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB";
3906 3906
         $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB";
3907 3907
         $details['memoryLimit'] = ini_get('memory_limit');
3908 3908
 
3909 3909
         if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
3910
-            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
3910
+            $details['loadTime'] = (string)round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
3911 3911
         }
3912 3912
 
3913 3913
         if ($details['mimeType'] == 'image/png') {
@@ -3999,7 +3999,7 @@  discard block
 block discarded – undo
3999 3999
         $log = null;
4000 4000
         $this->log("### Summary of verbose log");
4001 4001
         $this->log("As JSON: \n" . $this->json());
4002
-        $this->log("Memory peak: " . round(memory_get_peak_usage() /1024/1024) . "M");
4002
+        $this->log("Memory peak: " . round(memory_get_peak_usage()/1024/1024) . "M");
4003 4003
         $this->log("Memory limit: " . ini_get('memory_limit'));
4004 4004
 
4005 4005
         $included = get_included_files();
@@ -4407,7 +4407,7 @@  discard block
 block discarded – undo
4407 4407
 /**
4408 4408
  * Custom exception handler.
4409 4409
  */
4410
-set_exception_handler(function ($exception) {
4410
+set_exception_handler(function($exception) {
4411 4411
     errorPage(
4412 4412
         "<p><b>img.php: Uncaught exception:</b> <p>"
4413 4413
         . $exception->getMessage()
@@ -4424,7 +4424,7 @@  discard block
 block discarded – undo
4424 4424
  * Get configuration options from file, if the file exists, else use $config
4425 4425
  * if its defined or create an empty $config.
4426 4426
  */
4427
-$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
4427
+$configFile = __DIR__ . '/' . basename(__FILE__, '.php') . '_config.php';
4428 4428
 
4429 4429
 if (is_file($configFile)) {
4430 4430
     $config = require $configFile;
@@ -4800,7 +4800,7 @@  discard block
 block discarded – undo
4800 4800
  * Manage size constants from config file, use constants to replace values
4801 4801
  * for width and height.
4802 4802
  */
4803
-$sizeConstant = getConfig('size_constant', function () {
4803
+$sizeConstant = getConfig('size_constant', function() {
4804 4804
 
4805 4805
     // Set sizes to map constant to value, easier to use with width or height
4806 4806
     $sizes = array(
@@ -4814,7 +4814,7 @@  discard block
 block discarded – undo
4814 4814
     $gridColumns     = 24;
4815 4815
 
4816 4816
     for ($i = 1; $i <= $gridColumns; $i++) {
4817
-        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
4817
+        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth)*$i - $gridGutterWidth;
4818 4818
     }
4819 4819
 
4820 4820
     return $sizes;
@@ -4836,7 +4836,7 @@  discard block
 block discarded – undo
4836 4836
 }
4837 4837
 
4838 4838
 // Support width as % of original width
4839
-if ($newWidth && $newWidth[strlen($newWidth)-1] == '%') {
4839
+if ($newWidth && $newWidth[strlen($newWidth) - 1] == '%') {
4840 4840
     is_numeric(substr($newWidth, 0, -1))
4841 4841
         or errorPage('Width % not numeric.', 404);
4842 4842
 } else {
@@ -4861,7 +4861,7 @@  discard block
 block discarded – undo
4861 4861
 }
4862 4862
 
4863 4863
 // height
4864
-if ($newHeight && $newHeight[strlen($newHeight)-1] == '%') {
4864
+if ($newHeight && $newHeight[strlen($newHeight) - 1] == '%') {
4865 4865
     is_numeric(substr($newHeight, 0, -1))
4866 4866
         or errorPage('Height % out of range.', 404);
4867 4867
 } else {
@@ -4878,7 +4878,7 @@  discard block
 block discarded – undo
4878 4878
  * aspect-ratio, ar - affecting the resulting image width, height and resize options
4879 4879
  */
4880 4880
 $aspectRatio         = get(array('aspect-ratio', 'ar'));
4881
-$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {
4881
+$aspectRatioConstant = getConfig('aspect_ratio_constant', function() {
4882 4882
     return array(
4883 4883
         '3:1'    => 3/1,
4884 4884
         '3:2'    => 3/2,
@@ -4900,7 +4900,7 @@  discard block
 block discarded – undo
4900 4900
 }
4901 4901
 
4902 4902
 if ($negateAspectRatio) {
4903
-    $aspectRatio = 1 / $aspectRatio;
4903
+    $aspectRatio = 1/$aspectRatio;
4904 4904
 }
4905 4905
 
4906 4906
 is_null($aspectRatio)
@@ -4964,7 +4964,7 @@  discard block
 block discarded – undo
4964 4964
 if ($fillToFit !== null) {
4965 4965
 
4966 4966
     if (!empty($fillToFit)) {
4967
-        $bgColor   = $fillToFit;
4967
+        $bgColor = $fillToFit;
4968 4968
         verbose("fillToFit changed bgColor to = $bgColor");
4969 4969
     }
4970 4970
 
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
     /**
237
-    * Constructor
238
-    *
239
-    */
237
+     * Constructor
238
+     *
239
+     */
240 240
     public function __construct()
241 241
     {
242 242
         $this->request['header'] = array();
@@ -1333,8 +1333,8 @@  discard block
 block discarded – undo
1333 1333
     /**
1334 1334
      * Path to command to optimize jpeg images, for example jpegtran or null.
1335 1335
      */
1336
-     private $jpegOptimize;
1337
-     private $jpegOptimizeCmd;
1336
+        private $jpegOptimize;
1337
+        private $jpegOptimizeCmd;
1338 1338
 
1339 1339
 
1340 1340
 
@@ -1505,8 +1505,8 @@  discard block
 block discarded – undo
1505 1505
 
1506 1506
 
1507 1507
     /**
1508
-    * Disable the fasttrackCacke to start with, inject an object to enable it.
1509
-    */
1508
+     * Disable the fasttrackCacke to start with, inject an object to enable it.
1509
+     */
1510 1510
     private $fastTrackCache = null;
1511 1511
 
1512 1512
 
@@ -1536,9 +1536,9 @@  discard block
 block discarded – undo
1536 1536
     /*
1537 1537
      * Image copy strategy, defaults to RESAMPLE.
1538 1538
      */
1539
-     const RESIZE = 1;
1540
-     const RESAMPLE = 2;
1541
-     private $copyStrategy = NULL;
1539
+        const RESIZE = 1;
1540
+        const RESAMPLE = 2;
1541
+        private $copyStrategy = NULL;
1542 1542
 
1543 1543
 
1544 1544
 
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
         $this->crop      = $this->cropOrig;
2364 2364
 
2365 2365
         $this->initDimensions()
2366
-             ->calculateNewWidthAndHeight();
2366
+                ->calculateNewWidthAndHeight();
2367 2367
 
2368 2368
         return $this;
2369 2369
     }
@@ -2794,14 +2794,14 @@  discard block
 block discarded – undo
2794 2794
         if ($this->rotateBefore) {
2795 2795
             $this->log("Rotating image.");
2796 2796
             $this->rotate($this->rotateBefore, $this->bgColor)
2797
-                 ->reCalculateDimensions();
2797
+                    ->reCalculateDimensions();
2798 2798
         }
2799 2799
 
2800 2800
         // Auto-rotate image
2801 2801
         if ($this->autoRotate) {
2802 2802
             $this->log("Auto rotating image.");
2803 2803
             $this->rotateExif()
2804
-                 ->reCalculateDimensions();
2804
+                    ->reCalculateDimensions();
2805 2805
         }
2806 2806
 
2807 2807
         // Scale the original image before starting
@@ -2828,11 +2828,11 @@  discard block
 block discarded – undo
2828 2828
      *
2829 2829
      * @return $this
2830 2830
      */
2831
-     public function setCopyResizeStrategy($strategy)
2832
-     {
2833
-         $this->copyStrategy = $strategy;
2834
-         return $this;
2835
-     }
2831
+        public function setCopyResizeStrategy($strategy)
2832
+        {
2833
+            $this->copyStrategy = $strategy;
2834
+            return $this;
2835
+        }
2836 2836
 
2837 2837
 
2838 2838
 
@@ -3343,7 +3343,7 @@  discard block
 block discarded – undo
3343 3343
      * @param string $color as hex value.
3344 3344
      *
3345 3345
      * @return $this
3346
-    */
3346
+     */
3347 3347
     public function setDefaultBackgroundColor($color)
3348 3348
     {
3349 3349
         $this->log("Setting default background color to '$color'.");
@@ -3395,7 +3395,7 @@  discard block
 block discarded – undo
3395 3395
      * @param resource $img the image to work with or null if using $this->image.
3396 3396
      *
3397 3397
      * @return color value or null if no background color is set.
3398
-    */
3398
+     */
3399 3399
     private function getBackgroundColor($img = null)
3400 3400
     {
3401 3401
         $img = isset($img) ? $img : $this->image;
@@ -3429,7 +3429,7 @@  discard block
 block discarded – undo
3429 3429
      * @param int $height of the new image.
3430 3430
      *
3431 3431
      * @return image resource.
3432
-    */
3432
+     */
3433 3433
     private function createImageKeepTransparency($width, $height)
3434 3434
     {
3435 3435
         $this->log("Creating a new working image width={$width}px, height={$height}px.");
@@ -3674,8 +3674,8 @@  discard block
 block discarded – undo
3674 3674
 
3675 3675
         // Prepare
3676 3676
         $this->setSaveFolder($cache)
3677
-             ->setSource($src, $dir)
3678
-             ->generateFilename(null, false, 'srgb_');
3677
+                ->setSource($src, $dir)
3678
+                ->generateFilename(null, false, 'srgb_');
3679 3679
 
3680 3680
         // Check if the cached version is accurate.
3681 3681
         if ($useCache && is_readable($this->cacheFileName)) {
Please login to merge, or discard this patch.
a/vendor/mos/cimage/webroot/test/template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 <p>The following images are used for this test.</p>
30 30
 
31
-<?php foreach($images as $image) : ?>
31
+<?php foreach ($images as $image) : ?>
32 32
   <p>
33 33
     <code>
34 34
       <a href="img/<?=$image?>"><?=$image?></a> 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 <p>The following testcases are used for each image.</p>
52 52
 
53
-<?php foreach($testcase as $tc) : ?>
53
+<?php foreach ($testcase as $tc) : ?>
54 54
   <code><?=$tc?></code><br>
55 55
 <?php endforeach; ?>
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
 <?php 
62 62
 $ch1 = 1;
63
-foreach($images as $image) :
63
+foreach ($images as $image) :
64 64
 ?>
65 65
 <h3><?=$ch1?>. Using source image <?=$image?></h3>
66 66
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 <?php 
81 81
 $ch2 = 1;
82
-foreach($testcase as $tc) : 
82
+foreach ($testcase as $tc) : 
83 83
 $tcId = "$ch1.$ch2";
84 84
 ?>
85 85
 <h4>Testcase <?=$tcId?>: <?=$tc?></h4>
Please login to merge, or discard this patch.
a/vendor/mos/cimage/webroot/test/test.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 <?php
12 12
 $testcase = array(
13
-  array('text'=>'Original image', 'query'=>''),
14
-  array('text'=>'Crop out a rectangle of 100x100, start by position 200x200.', 'query'=>'&crop=100,100,200,200'),
15
-  array('text'=>'Crop out a full width rectangle with height of 200, start by position 0x100.', 'query'=>'&crop=0,200,0,100'),
16
-  array('text'=>'Max width 200.', 'query'=>'&w=200'),
17
-  array('text'=>'Max height 200.', 'query'=>'&h=200'),
18
-  array('text'=>'Max width 200 and max height 200.', 'query'=>'&w=200&h=200'),
19
-  array('text'=>'No-ratio makes image fit in area of width 200 and height 200.', 'query'=>'&w=200&h=200&no-ratio'),
20
-  array('text'=>'Crop to fit in width 200 and height 200.', 'query'=>'&w=200&h=200&crop-to-fit'),
21
-  array('text'=>'Crop to fit in width 200 and height 100.', 'query'=>'&w=200&h=100&crop-to-fit'),
22
-  array('text'=>'Crop to fit in width 100 and height 200.', 'query'=>'&w=100&h=200&crop-to-fit'),
23
-  array('text'=>'Quality 70', 'query'=>'&w=200&h=200&quality=70'),
24
-  array('text'=>'Quality 40', 'query'=>'&w=200&h=200&quality=40'),
25
-  array('text'=>'Quality 10', 'query'=>'&w=200&h=200&quality=10'),
26
-  array('text'=>'Filter: Negate', 'query'=>'&w=200&h=200&f=negate'),
27
-  array('text'=>'Filter: Grayscale', 'query'=>'&w=200&h=200&f=grayscale'),
28
-  array('text'=>'Filter: Brightness 90', 'query'=>'&w=200&h=200&f=brightness,90'),
29
-  array('text'=>'Filter: Contrast 50', 'query'=>'&w=200&h=200&f=contrast,50'),
30
-  array('text'=>'Filter: Colorize 0,255,0,0', 'query'=>'&w=200&h=200&f=colorize,0,255,0,0'),
31
-  array('text'=>'Filter: Edge detect', 'query'=>'&w=200&h=200&f=edgedetect'),
32
-  array('text'=>'Filter: Emboss', 'query'=>'&w=200&h=200&f=emboss'),
33
-  array('text'=>'Filter: Gaussian blur', 'query'=>'&w=200&h=200&f=gaussian_blur'),
34
-  array('text'=>'Filter: Selective blur', 'query'=>'&w=200&h=200&f=selective_blur'),
35
-  array('text'=>'Filter: Mean removal', 'query'=>'&w=200&h=200&f=mean_removal'),
36
-  array('text'=>'Filter: Smooth 2', 'query'=>'&w=200&h=200&f=smooth,2'),
37
-  array('text'=>'Filter: Pixelate 10,10', 'query'=>'&w=200&h=200&f=pixelate,10,10'),
38
-  array('text'=>'Multiple filter: Negate, Grayscale and Pixelate 10,10', 'query'=>'&w=200&h=200&&f=negate&f0=grayscale&f1=pixelate,10,10'),
39
-  array('text'=>'Crop with width & height and crop-to-fit with quality and filter', 'query'=>'&crop=100,100,100,100&w=200&h=200&crop-to-fit&q=70&f0=grayscale'),
13
+    array('text'=>'Original image', 'query'=>''),
14
+    array('text'=>'Crop out a rectangle of 100x100, start by position 200x200.', 'query'=>'&crop=100,100,200,200'),
15
+    array('text'=>'Crop out a full width rectangle with height of 200, start by position 0x100.', 'query'=>'&crop=0,200,0,100'),
16
+    array('text'=>'Max width 200.', 'query'=>'&w=200'),
17
+    array('text'=>'Max height 200.', 'query'=>'&h=200'),
18
+    array('text'=>'Max width 200 and max height 200.', 'query'=>'&w=200&h=200'),
19
+    array('text'=>'No-ratio makes image fit in area of width 200 and height 200.', 'query'=>'&w=200&h=200&no-ratio'),
20
+    array('text'=>'Crop to fit in width 200 and height 200.', 'query'=>'&w=200&h=200&crop-to-fit'),
21
+    array('text'=>'Crop to fit in width 200 and height 100.', 'query'=>'&w=200&h=100&crop-to-fit'),
22
+    array('text'=>'Crop to fit in width 100 and height 200.', 'query'=>'&w=100&h=200&crop-to-fit'),
23
+    array('text'=>'Quality 70', 'query'=>'&w=200&h=200&quality=70'),
24
+    array('text'=>'Quality 40', 'query'=>'&w=200&h=200&quality=40'),
25
+    array('text'=>'Quality 10', 'query'=>'&w=200&h=200&quality=10'),
26
+    array('text'=>'Filter: Negate', 'query'=>'&w=200&h=200&f=negate'),
27
+    array('text'=>'Filter: Grayscale', 'query'=>'&w=200&h=200&f=grayscale'),
28
+    array('text'=>'Filter: Brightness 90', 'query'=>'&w=200&h=200&f=brightness,90'),
29
+    array('text'=>'Filter: Contrast 50', 'query'=>'&w=200&h=200&f=contrast,50'),
30
+    array('text'=>'Filter: Colorize 0,255,0,0', 'query'=>'&w=200&h=200&f=colorize,0,255,0,0'),
31
+    array('text'=>'Filter: Edge detect', 'query'=>'&w=200&h=200&f=edgedetect'),
32
+    array('text'=>'Filter: Emboss', 'query'=>'&w=200&h=200&f=emboss'),
33
+    array('text'=>'Filter: Gaussian blur', 'query'=>'&w=200&h=200&f=gaussian_blur'),
34
+    array('text'=>'Filter: Selective blur', 'query'=>'&w=200&h=200&f=selective_blur'),
35
+    array('text'=>'Filter: Mean removal', 'query'=>'&w=200&h=200&f=mean_removal'),
36
+    array('text'=>'Filter: Smooth 2', 'query'=>'&w=200&h=200&f=smooth,2'),
37
+    array('text'=>'Filter: Pixelate 10,10', 'query'=>'&w=200&h=200&f=pixelate,10,10'),
38
+    array('text'=>'Multiple filter: Negate, Grayscale and Pixelate 10,10', 'query'=>'&w=200&h=200&&f=negate&f0=grayscale&f1=pixelate,10,10'),
39
+    array('text'=>'Crop with width & height and crop-to-fit with quality and filter', 'query'=>'&crop=100,100,100,100&w=200&h=200&crop-to-fit&q=70&f0=grayscale'),
40 40
 );
41 41
 ?>
42 42
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 <tbody>
48 48
 <?php
49 49
 foreach($testcase as $key => $val) {
50
-  $url = "../img.php?src=wider.jpg{$val['query']}";
51
-  echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
50
+    $url = "../img.php?src=wider.jpg{$val['query']}";
51
+    echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
52 52
 }
53 53
 ?>
54 54
 </tbody>
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 <tbody>
62 62
 <?php
63 63
 foreach($testcase as $key => $val) {
64
-  $url = "../img.php?src=higher.jpg{$val['query']}";
65
-  echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
64
+    $url = "../img.php?src=higher.jpg{$val['query']}";
65
+    echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
66 66
 }
67 67
 ?>
68 68
 </tbody>
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 <thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>
47 47
 <tbody>
48 48
 <?php
49
-foreach($testcase as $key => $val) {
49
+foreach ($testcase as $key => $val) {
50 50
   $url = "../img.php?src=wider.jpg{$val['query']}";
51
-  echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
51
+  echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>" . htmlentities($url) . "</a></code></td><td><img src='$url' /></td></tr>";
52 52
 }
53 53
 ?>
54 54
 </tbody>
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 <thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>
61 61
 <tbody>
62 62
 <?php
63
-foreach($testcase as $key => $val) {
63
+foreach ($testcase as $key => $val) {
64 64
   $url = "../img.php?src=higher.jpg{$val['query']}";
65
-  echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
65
+  echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>" . htmlentities($url) . "</a></code></td><td><img src='$url' /></td></tr>";
66 66
 }
67 67
 ?>
68 68
 </tbody>
Please login to merge, or discard this patch.
a/vendor/mos/cimage/webroot/test/test_issue38.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
 
26 26
 // For each image, apply these testcases
27
-$cache =  "&nc"; // ""; // "&nc"
27
+$cache = "&nc"; // ""; // "&nc"
28 28
 $testcase = array(
29 29
     "$cache&w=300&h=300&fill-to-fit",
30 30
     "$cache&w=200&h=400&fill-to-fit",
Please login to merge, or discard this patch.