Skip to content

Commit

Permalink
ENGCOM-21154: Add watermark processing in media application
Browse files Browse the repository at this point in the history
  • Loading branch information
progreg committed Feb 19, 2019
1 parent 9cdc1b7 commit c7930eb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/code/Magento/MediaStorage/Service/ImageResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,41 @@ private function resize(array $viewImage, string $originalImagePath, string $ori
]
);

if (isset($imageParams['watermark_file'])) {
if ($imageParams['watermark_height'] !== null) {
$image->setWatermarkHeight($imageParams['watermark_height']);
}

if ($imageParams['watermark_width'] !== null) {
$image->setWatermarkWidth($imageParams['watermark_width']);
}

if ($imageParams['watermark_position'] !== null) {
$image->setWatermarkPosition($imageParams['watermark_position']);
}

if ($imageParams['watermark_image_opacity'] !== null) {
$image->setWatermarkImageOpacity($imageParams['watermark_image_opacity']);
}

$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());
}

/**
* Returns watermark file absolute path
*
* @param string $file
* @return string
*/
private function getWatermarkFilePath($file)
{
$path = $this->imageConfig->getMediaPath('/watermark/' . $file);
return $this->mediaDirectory->getAbsolutePath($path);
}
}

1 comment on commit c7930eb

@vishalpatel19862
Copy link

@vishalpatel19862 vishalpatel19862 commented on c7930eb Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied this file at given location still product images are not showing on product list page and water mark not showing on images on product page. I am using Magento 2.3.1

Please sign in to comment.