Skip to content

Commit

Permalink
ENGCOM-6261: Relocate Watermark insert on image after resize. #25514 #…
Browse files Browse the repository at this point in the history
…25528

 - Merge Pull Request #25528 from Krielkip/magento2:bug/25514
 - Merged commits:
   1. 85415ef
   2. 2263d2e
  • Loading branch information
magento-engcom-team committed Nov 11, 2019
2 parents 3efbe15 + 2263d2e commit ef57281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 8 additions & 6 deletions app/code/Magento/Catalog/Model/Product/Image/ParamsBuilder.php
Expand Up @@ -130,10 +130,12 @@ private function getWatermark(string $type, int $scopeId = null): array
);

if ($file) {
$size = $this->scopeConfig->getValue(
"design/watermark/{$type}_size",
ScopeInterface::SCOPE_STORE,
$scopeId
$size = explode(
'x',
$this->scopeConfig->getValue(
"design/watermark/{$type}_size",
ScopeInterface::SCOPE_STORE
)
);
$opacity = $this->scopeConfig->getValue(
"design/watermark/{$type}_imageOpacity",
Expand All @@ -145,8 +147,8 @@ private function getWatermark(string $type, int $scopeId = null): array
ScopeInterface::SCOPE_STORE,
$scopeId
);
$width = !empty($size['width']) ? $size['width'] : null;
$height = !empty($size['height']) ? $size['height'] : null;
$width = !empty($size['0']) ? $size['0'] : null;
$height = !empty($size['1']) ? $size['1'] : null;

return [
'watermark_file' => $file,
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/MediaStorage/Service/ImageResize.php
Expand Up @@ -311,6 +311,10 @@ private function resize(array $imageParams, string $originalImagePath, string $o
]
);

if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
$image->resize($imageParams['image_width'], $imageParams['image_height']);
}

if (isset($imageParams['watermark_file'])) {
if ($imageParams['watermark_height'] !== null) {
$image->setWatermarkHeight($imageParams['watermark_height']);
Expand All @@ -331,9 +335,6 @@ private function resize(array $imageParams, string $originalImagePath, string $o
$image->watermark($this->getWatermarkFilePath($imageParams['watermark_file']));
}

if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
$image->resize($imageParams['image_width'], $imageParams['image_height']);
}
$image->save($imageAsset->getPath());

if ($this->fileStorageDatabase->checkDbUsage()) {
Expand Down

0 comments on commit ef57281

Please sign in to comment.