diff options
author | Georg Ehrke <developer@georgehrke.com> | 2013-08-15 13:21:35 +0200 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2013-08-15 13:22:05 +0200 |
commit | 825d8610d0abbf1063df3019533253908142ae43 (patch) | |
tree | be4e2cf9b808976d9ffa6cabebff7917eacb79db /lib | |
parent | 7fe9320ffe60d9f8346f424a235bbc51c99f9484 (diff) | |
download | nextcloud-server-825d8610d0abbf1063df3019533253908142ae43.tar.gz nextcloud-server-825d8610d0abbf1063df3019533253908142ae43.zip |
fix svg and cache transparency issue
Diffstat (limited to 'lib')
-rw-r--r-- | lib/image.php | 3 | ||||
-rwxr-xr-x | lib/preview.php | 2 | ||||
-rw-r--r-- | lib/preview/svg.php | 8 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/image.php b/lib/image.php index 4bc38e20e56..53ffb24d18c 100644 --- a/lib/image.php +++ b/lib/image.php @@ -496,6 +496,9 @@ class OC_Image { return false; } $this->resource = @imagecreatefromstring($str); + imagealphablending($this->resource, false); + imagesavealpha($this->resource, true); + if(!$this->resource) { OC_Log::write('core', 'OC_Image->loadFromData, couldn\'t load', OC_Log::DEBUG); return false; diff --git a/lib/preview.php b/lib/preview.php index 293accb188a..e7dd327d021 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -391,6 +391,8 @@ class Preview { continue; } + \OC_Log::write('core', 'Generating preview for "' . $file . '" with "' . get_class($provider) . '"', \OC_Log::DEBUG); + $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileview); if(!($preview instanceof \OC_Image)) { diff --git a/lib/preview/svg.php b/lib/preview/svg.php index e939e526b1b..b49e51720fa 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -18,7 +18,7 @@ if (extension_loaded('imagick')) { public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { try{ $svg = new \Imagick(); - $svg->setResolution($maxX, $maxY); + $svg->setBackgroundColor(new \ImagickPixel('transparent')); $content = stream_get_contents($fileview->fopen($path, 'r')); if(substr($content, 0, 5) !== '<?xml') { @@ -26,14 +26,16 @@ if (extension_loaded('imagick')) { } $svg->readImageBlob($content); - $svg->setImageFormat('jpg'); + $svg->setImageFormat('png32'); } catch (\Exception $e) { \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); return false; } + //new image object - $image = new \OC_Image($svg); + $image = new \OC_Image(); + $image->loadFromData($svg); //check if image object is valid return $image->valid() ? $image : false; } |