Skip to content

Commit 0b3eb60

Browse files
committed
round image dimensions to make them compatible with php 8 (gd2/imagemagik)
1 parent e4a5081 commit 0b3eb60

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,9 @@ protected function _adaptResizeValues($frameWidth, $frameHeight)
577577

578578
return [
579579
'src' => ['x' => $srcX, 'y' => $srcY],
580-
'dst' => ['x' => $dstX, 'y' => $dstY, 'width' => $dstWidth, 'height' => $dstHeight],
580+
'dst' => ['x' => $dstX, 'y' => $dstY, 'width' => round($dstWidth), 'height' => round($dstHeight)],
581581
// size for new image
582-
'frame' => ['width' => $frameWidth, 'height' => $frameHeight]
582+
'frame' => ['width' => round($frameWidth), 'height' => round($frameHeight)]
583583
];
584584
}
585585

lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ public function resize($frameWidth = null, $frameHeight = null)
212212

213213
$newImage = new \Imagick();
214214
$newImage->newImage(
215-
floor($dims['frame']['width']),
216-
floor($dims['frame']['height']),
215+
$dims['frame']['width'],
216+
$dims['frame']['height'],
217217
$this->_imageHandler->getImageBackgroundColor()
218218
);
219219

220220
$this->_imageHandler->resizeImage(
221-
floor($dims['dst']['width']),
222-
floor($dims['dst']['height']),
221+
$dims['dst']['width'],
222+
$dims['dst']['height'],
223223
\Imagick::FILTER_CUBIC,
224224
self::BLUR_FACTOR
225225
);

lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function adaptResizeValuesDataProvider()
9898
'frame' => ['width' => 135, 'height' => 135],
9999
];
100100

101-
return [[135, null, $expected], [null, 135, $expected]];
101+
return [[134.5, null, $expected], [null, 134.5, $expected]];
102102
}
103103

104104
/**

0 commit comments

Comments
 (0)