Skip to content

Commit 43d40df

Browse files
chrisryanchadicus
authored andcommitted
TESTING - Remove 2x2 binning loop.
1 parent ce2153e commit 43d40df

1 file changed

Lines changed: 11 additions & 23 deletions

File tree

src/Image.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,31 +155,19 @@ public static function resize(Imagick $source, int $boxWidth, int $boxHeight, ar
155155
}
156156
}
157157

158-
//do iterative downsize by halfs (2x2 binning is a common name) on dimensions that are bigger than target
159-
//width and height
160-
while (true) {
161-
$widthReduced = false;
162-
if ($width > $targetWidth) {
163-
$width = (int)($width / 2);
164-
$widthReduced = true;
165-
if ($width < $targetWidth) {
166-
$width = $targetWidth;
167-
}
168-
}
169-
170-
$heightReduced = false;
171-
if ($height > $targetHeight) {
172-
$height = (int)($height / 2);
173-
$heightReduced = true;
174-
if ($height < $targetHeight) {
175-
$height = $targetHeight;
176-
}
177-
}
158+
$widthReduced = false;
159+
if ($width > $targetWidth) {
160+
$width = $targetWidth;
161+
$widthReduced = true;
162+
}
178163

179-
if (!$widthReduced && !$heightReduced) {
180-
break;
181-
}
164+
$heightReduced = false;
165+
if ($height > $targetHeight) {
166+
$height = $targetHeight;
167+
$heightReduced = true;
168+
}
182169

170+
if ($widthReduced || $heightReduced) {
183171
if ($clone->resizeImage($width, $height, \Imagick::FILTER_BOX, 1.0) !== true) {
184172
//cumbersome to test
185173
throw new \Exception('Imagick::resizeImage() did not return true');//@codeCoverageIgnore

0 commit comments

Comments
 (0)