Skip to content

Commit cd38245

Browse files
MAGETWO-69238: Keep transparency when resizing images [2.1 backport] #9662
2 parents 84675bb + a647d77 commit cd38245

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/internal/Magento/Framework/Image/Adapter/Gd2.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ public function resize($frameWidth = null, $frameHeight = null)
346346
$newImage = imagecreate($dims['frame']['width'], $dims['frame']['height']);
347347
}
348348

349+
if ($isAlpha) {
350+
$this->_saveAlpha($newImage);
351+
}
352+
349353
// fill new image with required color
350354
$this->_fillBackgroundColor($newImage);
351355

lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ public function resize($frameWidth = null, $frameHeight = null)
168168
);
169169
}
170170

171+
$newImage->compositeImage(
172+
$this->_imageHandler,
173+
\Imagick::COMPOSITE_COPYOPACITY,
174+
$dims['dst']['x'],
175+
$dims['dst']['y']
176+
);
177+
171178
$newImage->compositeImage(
172179
$this->_imageHandler,
173180
\Imagick::COMPOSITE_OVER,

0 commit comments

Comments
 (0)