Skip to content

Relocate Watermark insert on image after resize. #25514 #25528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/code/Magento/Catalog/Model/Product/Image/ParamsBuilder.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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