From 3816825f8e339c18d4cd52742ccfe96154830d03 Mon Sep 17 00:00:00 2001 From: Rafael Kassner Date: Fri, 4 Nov 2016 11:13:41 +0200 Subject: [PATCH 1/3] Keep transparency when resizing images --- lib/internal/Magento/Framework/Image/Adapter/Gd2.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php index 15505d3fd6439..cce84467e665c 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); From 16545aaa4b4ecd05930fe972d813330ff94def1c Mon Sep 17 00:00:00 2001 From: Rafael Kassner Date: Wed, 18 Jan 2017 10:39:46 +0100 Subject: [PATCH 2/3] Keep transparency when resizing images (Imagick) --- .../Magento/Framework/Image/Adapter/ImageMagick.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php index ffdde07768022..89bcdfc1aea37 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php +++ b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php @@ -175,6 +175,13 @@ public function resize($frameWidth = null, $frameHeight = null) $dims['dst']['y'] ); + $newImage->compositeImage( + $this->_imageHandler, + \Imagick::COMPOSITE_COPYOPACITY, + $dims['dst']['x'], + $dims['dst']['y'] + ); + $newImage->setImageFormat($this->_imageHandler->getImageFormat()); $this->_imageHandler->clear(); $this->_imageHandler->destroy(); From fbf648fa8accd2ac40f2d7d362c3e19c826753f5 Mon Sep 17 00:00:00 2001 From: Rafael Kassner Date: Fri, 20 Jan 2017 15:59:21 +0100 Subject: [PATCH 3/3] Keep transparency when resizing images (Imagick) --- lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php index 89bcdfc1aea37..48a6b3699a945 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php +++ b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php @@ -170,14 +170,14 @@ public function resize($frameWidth = null, $frameHeight = null) $newImage->compositeImage( $this->_imageHandler, - \Imagick::COMPOSITE_OVER, + \Imagick::COMPOSITE_COPYOPACITY, $dims['dst']['x'], $dims['dst']['y'] ); $newImage->compositeImage( $this->_imageHandler, - \Imagick::COMPOSITE_COPYOPACITY, + \Imagick::COMPOSITE_OVER, $dims['dst']['x'], $dims['dst']['y'] );