Save thumbnails as PNG to allow transparency
This commit is contained in:
committed by
Frédéric Guillot
parent
d3d5522432
commit
1a39c46620
@@ -69,7 +69,7 @@ class AvatarFileController extends BaseController
|
|||||||
$etag = md5($filename.$size);
|
$etag = md5($filename.$size);
|
||||||
|
|
||||||
$this->response->withCache(365 * 86400, $etag);
|
$this->response->withCache(365 * 86400, $etag);
|
||||||
$this->response->withContentType('image/jpeg');
|
$this->response->withContentType('image/png');
|
||||||
|
|
||||||
if ($this->request->getHeader('If-None-Match') !== '"'.$etag.'"') {
|
if ($this->request->getHeader('If-None-Match') !== '"'.$etag.'"') {
|
||||||
$this->response->send();
|
$this->response->send();
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class FileViewerController extends BaseController
|
|||||||
$etag = md5($filename);
|
$etag = md5($filename);
|
||||||
|
|
||||||
$this->response->withCache(5 * 86400, $etag);
|
$this->response->withCache(5 * 86400, $etag);
|
||||||
$this->response->withContentType('image/jpeg');
|
$this->response->withContentType('image/png');
|
||||||
|
|
||||||
if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
|
if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
|
||||||
$this->response->status(304);
|
$this->response->status(304);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Kanboard\Core;
|
|||||||
*/
|
*/
|
||||||
class Thumbnail
|
class Thumbnail
|
||||||
{
|
{
|
||||||
protected $quality = 95;
|
protected $compression = -1;
|
||||||
protected $metadata = array();
|
protected $metadata = array();
|
||||||
protected $srcImage;
|
protected $srcImage;
|
||||||
protected $dstImage;
|
protected $dstImage;
|
||||||
@@ -124,6 +124,9 @@ class Thumbnail
|
|||||||
$this->dstImage = imagecreatetruecolor($width, $height);
|
$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);
|
imagecopyresampled($this->dstImage, $this->srcImage, $dstX, $dstY, 0, 0, $dstWidth, $dstHeight, $srcWidth, $srcHeight);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -138,7 +141,7 @@ class Thumbnail
|
|||||||
*/
|
*/
|
||||||
public function toFile($filename)
|
public function toFile($filename)
|
||||||
{
|
{
|
||||||
imagejpeg($this->dstImage, $filename, $this->quality);
|
imagepng($this->dstImage, $filename, $this->compression);
|
||||||
imagedestroy($this->dstImage);
|
imagedestroy($this->dstImage);
|
||||||
imagedestroy($this->srcImage);
|
imagedestroy($this->srcImage);
|
||||||
return $this;
|
return $this;
|
||||||
@@ -153,7 +156,7 @@ class Thumbnail
|
|||||||
public function toString()
|
public function toString()
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
imagejpeg($this->dstImage, null, $this->quality);
|
imagepng($this->dstImage, null, $this->compression);
|
||||||
imagedestroy($this->dstImage);
|
imagedestroy($this->dstImage);
|
||||||
imagedestroy($this->srcImage);
|
imagedestroy($this->srcImage);
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
@@ -166,7 +169,7 @@ class Thumbnail
|
|||||||
*/
|
*/
|
||||||
public function toOutput()
|
public function toOutput()
|
||||||
{
|
{
|
||||||
imagejpeg($this->dstImage, null, $this->quality);
|
imagepng($this->dstImage, null, $this->compression);
|
||||||
imagedestroy($this->dstImage);
|
imagedestroy($this->dstImage);
|
||||||
imagedestroy($this->srcImage);
|
imagedestroy($this->srcImage);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user