Skip to content

Commit fb4ad35

Browse files
author
Oleksandr Iegorov
committed
MC-30296: Product image is not visible if a watermark image size is larger
1 parent 30991e6 commit fb4ad35

File tree

1 file changed

+2
-45
lines changed
  • lib/internal/Magento/Framework/Image/Adapter

1 file changed

+2
-45
lines changed

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

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity =
442442
$this->_getCallback('create', $watermarkFileType, 'Unsupported watermark image format.'),
443443
$imagePath
444444
);
445-
//$watermark = $this->prepareWatermark($watermark, $watermarkFileType);
446445

447446
$merged = false;
448447

@@ -600,49 +599,6 @@ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity =
600599
$this->refreshImageDimensions();
601600
}
602601

603-
/**
604-
* @param resource $watermark
605-
* @param string $watermarkFileType
606-
* @return resource
607-
*/
608-
private function prepareWatermark($watermark, $watermarkFileType)
609-
{
610-
if (imagesx($watermark) > $this->_imageSrcWidth
611-
|| imagesy($watermark) > $this->_imageSrcHeight) {
612-
$widthRatio = imagesx($watermark)/$this->_imageSrcWidth;
613-
$heightRatio = imagesy($watermark)/$this->_imageSrcHeight;
614-
$newWidth = ($widthRatio > $heightRatio)
615-
? round(imagesx($watermark)/$widthRatio) : round(imagesx($watermark)/$heightRatio);
616-
$newHeight = ($widthRatio > $heightRatio)
617-
? round(imagesy($watermark)/$widthRatio) : round(imagesy($watermark)/$heightRatio);
618-
$isAlpha = false;
619-
$isTrueColor = false;
620-
$this->_getTransparency($watermark, $watermarkFileType, $isAlpha, $isTrueColor);
621-
if ($isTrueColor) {
622-
$newImage = imagecreatetruecolor($newWidth, $newHeight);
623-
} else {
624-
$newImage = imagecreate($newWidth, $newHeight);
625-
}
626-
if ($isAlpha) {
627-
$this->_saveAlpha($newImage);
628-
}
629-
imagecopyresampled(
630-
$newImage,
631-
$watermark,
632-
0,
633-
0,
634-
0,
635-
0,
636-
$newWidth,
637-
$newHeight,
638-
imagesx($watermark),
639-
imagesy($watermark)
640-
);
641-
$watermark = $newImage;
642-
}
643-
return $watermark;
644-
}
645-
646602
/**
647603
* Crop image
648604
*
@@ -866,8 +822,9 @@ protected function _createEmptyImage($width, $height)
866822
* @param int $src_w
867823
* @param int $src_h
868824
* @param int $pct
869-
*
870825
* @return bool
826+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
827+
* @SuppressWarnings(PHPMD.NPathComplexity)
871828
*/
872829
private function imagecopymergeWithAlphaFix(
873830
$dst_im,

0 commit comments

Comments
 (0)