Skip to content
Snippets Groups Projects
Commit 51d050c9 authored by Frank Karlitschek's avatar Frank Karlitschek
Browse files

Merge pull request #1848 from owncloud/keep_transparency

keep transparency when resizing or cropping png/gif
parents 31d2b9bc 16a5f15f
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment