diff options
Diffstat (limited to 'lib/preview/svg.php')
-rw-r--r-- | lib/preview/svg.php | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 8bceeaf60d1..76d81589bac 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -16,17 +16,22 @@ if (extension_loaded('imagick')) { } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $svg = new \Imagick(); - $svg->setResolution($maxX, $maxY); - - $content = stream_get_contents($fileview->fopen($path, 'r')); - if(substr($content, 0, 5) !== '<?xml') { - $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content; + try{ + $svg = new \Imagick(); + $svg->setResolution($maxX, $maxY); + + $content = stream_get_contents($fileview->fopen($path, 'r')); + if(substr($content, 0, 5) !== '<?xml') { + $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content; + } + + $svg->readImageBlob($content); + $svg->setImageFormat('jpg'); + }catch(\Exception $e){ + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; } - $svg->readImageBlob($content); - $svg->setImageFormat('jpg'); - //new image object $image = new \OC_Image($svg); //check if image object is valid |