Skip to content

Commit

Permalink
Keep transparency when resizing images
Browse files Browse the repository at this point in the history
  • Loading branch information
kassner committed May 17, 2017
1 parent 84675bb commit 8774d3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/internal/Magento/Framework/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ public function resize($frameWidth = null, $frameHeight = null)
$newImage = imagecreate($dims['frame']['width'], $dims['frame']['height']);
}

if ($isAlpha) {
$this->_saveAlpha($newImage);
}

// fill new image with required color
$this->_fillBackgroundColor($newImage);

Expand Down
7 changes: 7 additions & 0 deletions lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ public function resize($frameWidth = null, $frameHeight = null)
);
}

$newImage->compositeImage(
$this->_imageHandler,
\Imagick::COMPOSITE_COPYOPACITY,
$dims['dst']['x'],
$dims['dst']['y']
);

$newImage->compositeImage(
$this->_imageHandler,
\Imagick::COMPOSITE_OVER,
Expand Down

0 comments on commit 8774d3c

Please sign in to comment.