Merge pull request #422 from acrox999/master

Retain PNG transparency.
This commit is contained in:
Diego Najar 2017-05-01 22:08:31 +02:00 committed by GitHub
commit 5a3c217cca
1 changed files with 4 additions and 0 deletions

View File

@ -108,6 +108,8 @@ class Image {
// *** Resample - create image canvas of x, y size // *** Resample - create image canvas of x, y size
$this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight); $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
imagealphablending($this->imageResized, false);
imagesavealpha($this->imageResized, true);
imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height); imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);
@ -230,6 +232,8 @@ class Image {
// *** Now crop from center to exact requested size // *** Now crop from center to exact requested size
$this->imageResized = imagecreatetruecolor($newWidth , $newHeight); $this->imageResized = imagecreatetruecolor($newWidth , $newHeight);
imagealphablending($this->imageResized, false);
imagesavealpha($this->imageResized, true);
imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight); imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight);
} }
} }