Completed
Push — 2.x ( 9f4939...53abae )
by Naoki
16:21
created
php/plugins/AutoResize/plugin.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
 	public function __construct($opts) {
54 54
 		$defaults = array(
55
-			'enable'         => true,       // For control by volume driver
56
-			'maxWidth'       => 1024,       // Path to Water mark image
57
-			'maxHeight'      => 1024,       // Margin right pixel
58
-			'quality'        => 95,         // JPEG image save quality
59
-			'preserveExif'   => false,      // Preserve EXIF data (Imagick only)
60
-			'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field )
55
+			'enable'         => true, // For control by volume driver
56
+			'maxWidth'       => 1024, // Path to Water mark image
57
+			'maxHeight'      => 1024, // Margin right pixel
58
+			'quality'        => 95, // JPEG image save quality
59
+			'preserveExif'   => false, // Preserve EXIF data (Imagick only)
60
+			'targetType'     => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field )
61 61
 		);
62 62
 
63 63
 		$this->opts = array_merge($defaults, $opts);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			$opts = array_merge($this->opts, $volOpts);
72 72
 		}
73 73
 		
74
-		if (! $opts['enable']) {
74
+		if (!$opts['enable']) {
75 75
 			return false;
76 76
 		}
77 77
 		
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 				IMAGETYPE_PNG => IMG_PNG,
88 88
 				IMAGETYPE_WBMP => IMG_WBMP,
89 89
 		);
90
-		if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
90
+		if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
91 91
 			return false;
92 92
 		}
93 93
 		
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 	
101 101
 	private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality, $preserveExif) {
102
-		$zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1]));
103
-		$width = round($srcImgInfo[0] * $zoom);
104
-		$height = round($srcImgInfo[1] * $zoom);
102
+		$zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1]));
103
+		$width = round($srcImgInfo[0]*$zoom);
104
+		$height = round($srcImgInfo[1]*$zoom);
105 105
 		
106 106
 		if (class_exists('Imagick', false)) {
107 107
 			return $this->resize_imagick($src, $width, $height, $quality, $preserveExif);
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 				break;
122 122
 			case 'image/jpeg':
123 123
 				if (@imagetypes() & IMG_JPG) {
124
-					$oSrcImg = @imagecreatefromjpeg($src) ;
124
+					$oSrcImg = @imagecreatefromjpeg($src);
125 125
 				} else {
126 126
 					$ermsg = 'JPEG images are not supported';
127 127
 				}
128 128
 				break;
129 129
 			case 'image/png':
130 130
 				if (@imagetypes() & IMG_PNG) {
131
-					$oSrcImg = @imagecreatefrompng($src) ;
131
+					$oSrcImg = @imagecreatefrompng($src);
132 132
 				} else {
133 133
 					$ermsg = 'PNG images are not supported';
134 134
 				}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 				break;
147 147
 		}
148 148
 		
149
-		if ($oSrcImg &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
149
+		if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) {
150 150
 			
151 151
 			if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) {
152 152
 				return false;
Please login to merge, or discard this patch.