diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 85878a122a8dab6eb6def8cbe5f3bc0910f49d86..f1d0a33dc630cbef13c880dfa0a556a210841668 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -19,8 +19,13 @@ if (extension_loaded('imagick')) { $tmppath = $fileview->toTmpFile($path); //create imagick object from pdf - $pdf = new \imagick($tmppath . '[0]'); - $pdf->setImageFormat('jpg'); + try{ + $pdf = new \imagick($tmppath . '[0]'); + $pdf->setImageFormat('jpg'); + }catch(\Exception $e){ + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } unlink($tmppath); diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 8bceeaf60d155a17ae87b321692fb4f62239fc01..76d81589bac475fb9762442a7fb539819dedb4ae 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