Skip to content
Snippets Groups Projects
Commit 825d8610 authored by Georg Ehrke's avatar Georg Ehrke
Browse files

fix svg and cache transparency issue

parent 7fe9320f
Branches
No related tags found
No related merge requests found
...@@ -496,6 +496,9 @@ class OC_Image { ...@@ -496,6 +496,9 @@ class OC_Image {
return false; return false;
} }
$this->resource = @imagecreatefromstring($str); $this->resource = @imagecreatefromstring($str);
imagealphablending($this->resource, false);
imagesavealpha($this->resource, true);
if(!$this->resource) { if(!$this->resource) {
OC_Log::write('core', 'OC_Image->loadFromData, couldn\'t load', OC_Log::DEBUG); OC_Log::write('core', 'OC_Image->loadFromData, couldn\'t load', OC_Log::DEBUG);
return false; return false;
......
...@@ -391,6 +391,8 @@ class Preview { ...@@ -391,6 +391,8 @@ class Preview {
continue; 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); $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileview);
if(!($preview instanceof \OC_Image)) { if(!($preview instanceof \OC_Image)) {
......
...@@ -18,7 +18,7 @@ if (extension_loaded('imagick')) { ...@@ -18,7 +18,7 @@ if (extension_loaded('imagick')) {
public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) {
try{ try{
$svg = new \Imagick(); $svg = new \Imagick();
$svg->setResolution($maxX, $maxY); $svg->setBackgroundColor(new \ImagickPixel('transparent'));
$content = stream_get_contents($fileview->fopen($path, 'r')); $content = stream_get_contents($fileview->fopen($path, 'r'));
if(substr($content, 0, 5) !== '<?xml') { if(substr($content, 0, 5) !== '<?xml') {
...@@ -26,14 +26,16 @@ if (extension_loaded('imagick')) { ...@@ -26,14 +26,16 @@ if (extension_loaded('imagick')) {
} }
$svg->readImageBlob($content); $svg->readImageBlob($content);
$svg->setImageFormat('jpg'); $svg->setImageFormat('png32');
} catch (\Exception $e) { } catch (\Exception $e) {
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false; return false;
} }
//new image object //new image object
$image = new \OC_Image($svg); $image = new \OC_Image();
$image->loadFromData($svg);
//check if image object is valid //check if image object is valid
return $image->valid() ? $image : false; return $image->valid() ? $image : false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment