Skip to content

Commit 2456e7d

Browse files
committed
Merge remote-tracking branch 'adobe-commerce-tier-4/ACP2E-3127' into Tier4-Kings-PR-07-24-2024
2 parents 1aaadaa + 79b8895 commit 2456e7d

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ public function resizeDataProvider()
296296
[$this->_getFixture('image_adapters_test.png'), [100, null]],
297297
[$this->_getFixture('image_adapters_test.png'), [null, null]],
298298
[$this->_getFixture('image_adapters_test.png'), [-100, -50]],
299+
[$this->_getFixture('image_adapters_test.png'), [200, 0]]
299300
]
300301
);
301302
}

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/**
1313
* Image abstract adapter
1414
*
15+
* phpcs:disable Magento2.Classes.AbstractApi
1516
* @api
1617
* @SuppressWarnings(PHPMD.TooManyFields)
1718
*/
@@ -27,25 +28,25 @@ abstract class AbstractAdapter implements AdapterInterface
2728
* Position constants.
2829
* Used mainly for watermarks
2930
*/
30-
const POSITION_TOP_LEFT = 'top-left';
31+
public const POSITION_TOP_LEFT = 'top-left';
3132

32-
const POSITION_TOP_RIGHT = 'top-right';
33+
public const POSITION_TOP_RIGHT = 'top-right';
3334

34-
const POSITION_BOTTOM_LEFT = 'bottom-left';
35+
public const POSITION_BOTTOM_LEFT = 'bottom-left';
3536

36-
const POSITION_BOTTOM_RIGHT = 'bottom-right';
37+
public const POSITION_BOTTOM_RIGHT = 'bottom-right';
3738

38-
const POSITION_STRETCH = 'stretch';
39+
public const POSITION_STRETCH = 'stretch';
3940

40-
const POSITION_TILE = 'tile';
41+
public const POSITION_TILE = 'tile';
4142

42-
const POSITION_CENTER = 'center';
43+
public const POSITION_CENTER = 'center';
4344
/**#@-*/
4445

4546
/**
4647
* The size of the font to use as default
4748
*/
48-
const DEFAULT_FONT_SIZE = 15;
49+
public const DEFAULT_FONT_SIZE = 15;
4950

5051
/**
5152
* @var int
@@ -604,7 +605,10 @@ protected function _checkAspectRatio($frameWidth, $frameHeight)
604605
}
605606
// keep aspect ratio
606607
if ($this->_imageSrcWidth / $this->_imageSrcHeight >= $frameWidth / $frameHeight) {
607-
$dstHeight = round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight);
608+
$dstHeight = max(
609+
1,
610+
round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight)
611+
);
608612
} else {
609613
$dstWidth = round($dstHeight / $this->_imageSrcHeight * $this->_imageSrcWidth);
610614
}
@@ -624,7 +628,7 @@ protected function _checkDimensions($frameWidth, $frameHeight)
624628
{
625629
if ($frameWidth !== null && $frameWidth <= 0 ||
626630
$frameHeight !== null && $frameHeight <= 0 ||
627-
empty($frameWidth) && empty($frameHeight)
631+
($frameWidth === null && $frameHeight === null)
628632
) {
629633
//phpcs:ignore Magento2.Exceptions.DirectThrow
630634
throw new \InvalidArgumentException('Invalid image dimensions.');

0 commit comments

Comments
 (0)