From 8774d3c79660038b1051f6586729728db3981754 Mon Sep 17 00:00:00 2001 From: Rafael Kassner Date: Wed, 17 May 2017 08:31:37 +0000 Subject: [PATCH] Keep transparency when resizing images --- lib/internal/Magento/Framework/Image/Adapter/Gd2.php | 4 ++++ .../Magento/Framework/Image/Adapter/ImageMagick.php | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php index c723ad48ba3d6..8bb76b6b94609 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php +++ b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php @@ -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); diff --git a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php index 93339dd8e800d..63fe81f41cc2a 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php +++ b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php @@ -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,