From 1a39c46620febdb22d8b0e4cadbbdeeefa00c3ac Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 10 Jul 2019 22:12:02 +0200 Subject: Save thumbnails as PNG to allow transparency --- app/Core/Thumbnail.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'app/Core') diff --git a/app/Core/Thumbnail.php b/app/Core/Thumbnail.php index fbe14d1b..ba93747a 100644 --- a/app/Core/Thumbnail.php +++ b/app/Core/Thumbnail.php @@ -10,7 +10,7 @@ namespace Kanboard\Core; */ class Thumbnail { - protected $quality = 95; + protected $compression = -1; protected $metadata = array(); protected $srcImage; protected $dstImage; @@ -124,6 +124,9 @@ class Thumbnail $this->dstImage = imagecreatetruecolor($width, $height); } + imagealphablending($this->dstImage, false); + imagesavealpha($this->dstImage, true); + imagecopyresampled($this->dstImage, $this->srcImage, $dstX, $dstY, 0, 0, $dstWidth, $dstHeight, $srcWidth, $srcHeight); return $this; @@ -138,7 +141,7 @@ class Thumbnail */ public function toFile($filename) { - imagejpeg($this->dstImage, $filename, $this->quality); + imagepng($this->dstImage, $filename, $this->compression); imagedestroy($this->dstImage); imagedestroy($this->srcImage); return $this; @@ -153,7 +156,7 @@ class Thumbnail public function toString() { ob_start(); - imagejpeg($this->dstImage, null, $this->quality); + imagepng($this->dstImage, null, $this->compression); imagedestroy($this->dstImage); imagedestroy($this->srcImage); return ob_get_clean(); @@ -166,7 +169,7 @@ class Thumbnail */ public function toOutput() { - imagejpeg($this->dstImage, null, $this->quality); + imagepng($this->dstImage, null, $this->compression); imagedestroy($this->dstImage); imagedestroy($this->srcImage); } -- cgit v1.2.3