summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKN4CK3R <KN4CK3R@users.noreply.github.com>2019-07-10 22:12:02 +0200
committerFrédéric Guillot <fred@kanboard.net>2019-07-10 13:12:02 -0700
commit1a39c46620febdb22d8b0e4cadbbdeeefa00c3ac (patch)
treeba31a11bede861a71f2c026115a712769cf987d7 /app
parentd3d55224329681722b52a84b31f141bf78aaa134 (diff)
Save thumbnails as PNG to allow transparency
Diffstat (limited to 'app')
-rw-r--r--app/Controller/AvatarFileController.php2
-rw-r--r--app/Controller/FileViewerController.php2
-rw-r--r--app/Core/Thumbnail.php11
3 files changed, 9 insertions, 6 deletions
diff --git a/app/Controller/AvatarFileController.php b/app/Controller/AvatarFileController.php
index 81a324fb..12c4069c 100644
--- a/app/Controller/AvatarFileController.php
+++ b/app/Controller/AvatarFileController.php
@@ -69,7 +69,7 @@ class AvatarFileController extends BaseController
$etag = md5($filename.$size);
$this->response->withCache(365 * 86400, $etag);
- $this->response->withContentType('image/jpeg');
+ $this->response->withContentType('image/png');
if ($this->request->getHeader('If-None-Match') !== '"'.$etag.'"') {
$this->response->send();
diff --git a/app/Controller/FileViewerController.php b/app/Controller/FileViewerController.php
index 49568912..0178cb30 100644
--- a/app/Controller/FileViewerController.php
+++ b/app/Controller/FileViewerController.php
@@ -116,7 +116,7 @@ class FileViewerController extends BaseController
$etag = md5($filename);
$this->response->withCache(5 * 86400, $etag);
- $this->response->withContentType('image/jpeg');
+ $this->response->withContentType('image/png');
if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
$this->response->status(304);
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);
}