fix svg and cache transparency issue
This commit is contained in:
parent
7fe9320ffe
commit
825d8610d0
|
@ -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 {
|
||||||
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')) {
|
||||||
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')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue