12
12
/**
13
13
* Image abstract adapter
14
14
*
15
+ * phpcs:disable Magento2.Classes.AbstractApi
15
16
* @api
16
17
* @SuppressWarnings(PHPMD.TooManyFields)
17
18
*/
@@ -27,25 +28,25 @@ abstract class AbstractAdapter implements AdapterInterface
27
28
* Position constants.
28
29
* Used mainly for watermarks
29
30
*/
30
- const POSITION_TOP_LEFT = 'top-left ' ;
31
+ public const POSITION_TOP_LEFT = 'top-left ' ;
31
32
32
- const POSITION_TOP_RIGHT = 'top-right ' ;
33
+ public const POSITION_TOP_RIGHT = 'top-right ' ;
33
34
34
- const POSITION_BOTTOM_LEFT = 'bottom-left ' ;
35
+ public const POSITION_BOTTOM_LEFT = 'bottom-left ' ;
35
36
36
- const POSITION_BOTTOM_RIGHT = 'bottom-right ' ;
37
+ public const POSITION_BOTTOM_RIGHT = 'bottom-right ' ;
37
38
38
- const POSITION_STRETCH = 'stretch ' ;
39
+ public const POSITION_STRETCH = 'stretch ' ;
39
40
40
- const POSITION_TILE = 'tile ' ;
41
+ public const POSITION_TILE = 'tile ' ;
41
42
42
- const POSITION_CENTER = 'center ' ;
43
+ public const POSITION_CENTER = 'center ' ;
43
44
/**#@-*/
44
45
45
46
/**
46
47
* The size of the font to use as default
47
48
*/
48
- const DEFAULT_FONT_SIZE = 15 ;
49
+ public const DEFAULT_FONT_SIZE = 15 ;
49
50
50
51
/**
51
52
* @var int
@@ -604,7 +605,10 @@ protected function _checkAspectRatio($frameWidth, $frameHeight)
604
605
}
605
606
// keep aspect ratio
606
607
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
+ );
608
612
} else {
609
613
$ dstWidth = round ($ dstHeight / $ this ->_imageSrcHeight * $ this ->_imageSrcWidth );
610
614
}
@@ -624,7 +628,7 @@ protected function _checkDimensions($frameWidth, $frameHeight)
624
628
{
625
629
if ($ frameWidth !== null && $ frameWidth <= 0 ||
626
630
$ frameHeight !== null && $ frameHeight <= 0 ||
627
- empty ($ frameWidth) && empty ( $ frameHeight )
631
+ ($ frameWidth === null && $ frameHeight === null )
628
632
) {
629
633
//phpcs:ignore Magento2.Exceptions.DirectThrow
630
634
throw new \InvalidArgumentException ('Invalid image dimensions. ' );
0 commit comments