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