@@ -17,7 +17,8 @@ public static function resize(\Imagick $source, int $boxWidth, int $boxHeight, a
1717 * resizes images into a bounding box. Maintains aspect ratio, extra space filled with given color.
1818 *
1919 * @param \Imagick $source source image to resize. Will not modify
20- * @param array $boxSizes resulting bounding boxes. Each value should be an array with width and height, both integers
20+ * @param array $boxSizes resulting bounding boxes. Each value should be an array with width and height, both
21+ * integers
2122 * @param array $options options
2223 * string color (default white) background color. Any supported from
2324 * http://www.imagemagick.org/script/color.php#color_names
@@ -39,10 +40,10 @@ public static function resize(\Imagick $source, int $boxWidth, int $boxHeight, a
3940 */
4041 public static function resizeMulti (\Imagick $ source , array $ boxSizes , array $ options = []) : array
4142 {
42- //algorithm inspiration from http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
43- //use of 2x2 binning is arguably the best quality one will get downsizing and is what lots of hardware does in the photography field,
44- //while being reasonably fast. Upsizing is more subjective but you can't get much better than bicubic which is what is used here.
45-
43+ //algorithm inspired from http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
44+ //use of 2x2 binning is arguably the best quality one will get downsizing and is what lots of hardware does in
45+ //the photography field, while being reasonably fast. Upsizing is more subjective but you can't get much
46+ //better than bicubic which is what is used here.
4647 $ color = 'white ' ;
4748 if (isset ($ options ['color ' ])) {
4849 $ color = $ options ['color ' ];
@@ -122,7 +123,8 @@ public static function resizeMulti(\Imagick $source, array $boxSizes, array $opt
122123
123124 //ratio over 1 is horizontal, under 1 is vertical
124125 $ boxRatio = $ boxWidth / $ boxHeight ;
125- $ originalRatio = $ width / $ height ;//height should be positive since I didnt find a way you could get zero into imagick
126+ //height should be positive since I didnt find a way you could get zero into imagick
127+ $ originalRatio = $ width / $ height ;
126128
127129 $ targetWidth = null ;
128130 $ targetHeight = null ;
@@ -148,7 +150,8 @@ public static function resizeMulti(\Imagick $source, array $boxSizes, array $opt
148150 }
149151 }
150152
151- //do iterative downsize by halfs (2x2 binning is a common name) on dimensions that are bigger than target width and height
153+ //do iterative downsize by halfs (2x2 binning is a common name) on dimensions that are bigger than target
154+ //width and height
152155 while (true ) {
153156 $ widthReduced = false ;
154157 $ widthIsHalf = false ;
@@ -213,8 +216,8 @@ public static function resizeMulti(\Imagick $source, array $boxSizes, array $opt
213216 throw new \Exception ('Imagick::compositeImage() did not return true ' );//@codeCoverageIgnore
214217 }
215218
216- //reason we are not supporting the options in self::write() here is because format, and strip headers are only relevant once written
217- //Imagick::stripImage() doesnt even have an effect until written
219+ //reason we are not supporting the options in self::write() here is because format, and strip headers are
220+ //only relevant once written Imagick::stripImage() doesnt even have an effect until written
218221 //also the user can just call that function with the resultant $canvas
219222 $ results [$ boxSizeKey ] = $ canvas ;
220223 }
@@ -228,10 +231,11 @@ public static function resizeMulti(\Imagick $source, array $boxSizes, array $opt
228231 * @param \Imagick $source source image. Will not modify
229232 * @param string $destPath destination image path
230233 * @param array $options options
231- * string format (default jpeg) format. Any supported from http://www.imagemagick.org/script/formats.php#supported
232- * int directoryMode (default 0777) chmod mode for any parent directories created
233- * int fileMode (default 0777) chmod mode for the resized image file
234- * bool stripHeaders (default true) whether to strip headers (exif, etc). Is only reflected in $destPath, not returned clone
234+ * string format (default jpeg) Any from http://www.imagemagick.org/script/formats.php#supported
235+ * int directoryMode (default 0777) chmod mode for any parent directories created
236+ * int fileMode (default 0777) chmod mode for the resized image file
237+ * bool stripHeaders (default true) whether to strip headers (exif, etc). Is only reflected in $destPath,
238+ * not returned clone
235239 *
236240 * @return void
237241 *
0 commit comments