diff options
author | Frank Karlitschek <frank@owncloud.org> | 2013-02-22 04:02:26 -0800 |
---|---|---|
committer | Frank Karlitschek <frank@owncloud.org> | 2013-02-22 04:02:26 -0800 |
commit | 51d050c93515215f5053113c617a4c49c4a4474e (patch) | |
tree | 0f7d98fe8d4fe7622674f32b27348408276ff093 /lib | |
parent | 31d2b9bc07980a872721d5c79230724ce387b41c (diff) | |
parent | 16a5f15f85cabfaa0c0fc66151e850119b64e64b (diff) | |
download | nextcloud-server-51d050c93515215f5053113c617a4c49c4a4474e.tar.gz nextcloud-server-51d050c93515215f5053113c617a4c49c4a4474e.zip |
Merge pull request #1848 from owncloud/keep_transparency
keep transparency when resizing or cropping png/gif
Diffstat (limited to 'lib')
-rw-r--r-- | lib/image.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/image.php b/lib/image.php index 7b0cbefd657..dc1c6df85ae 100644 --- a/lib/image.php +++ b/lib/image.php @@ -702,6 +702,13 @@ class OC_Image { return false; } + // preserve transparency + if($this->imagetype == IMAGETYPE_GIF or $this->imagetype == IMAGETYPE_PNG) { + imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127)); + imagealphablending($process, false); + imagesavealpha($process, true); + } + imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); if ($process == false) { OC_Log::write('core', __METHOD__.'(): Error resampling process image '.$width.'x'.$height, OC_Log::ERROR); @@ -751,6 +758,14 @@ class OC_Image { imagedestroy($process); return false; } + + // preserve transparency + if($this->imagetype == IMAGETYPE_GIF or $this->imagetype == IMAGETYPE_PNG) { + imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127)); + imagealphablending($process, false); + imagesavealpha($process, true); + } + imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height); if ($process == false) { OC_Log::write('core', |