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