aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <georg@ownCloud.com>2013-05-30 11:06:52 +0200
committerGeorg Ehrke <georg@ownCloud.com>2013-05-30 11:06:52 +0200
commita014662c52f5295a7e86cd43b7dd62b89e3f1085 (patch)
tree67a1368fbee73ab0c8c82feb9110718bcc097fdd
parent5433a5046194a5c618c4cfdd253317d8f0eac69f (diff)
downloadnextcloud-server-a014662c52f5295a7e86cd43b7dd62b89e3f1085.tar.gz
nextcloud-server-a014662c52f5295a7e86cd43b7dd62b89e3f1085.zip
improve imagick error handling
-rw-r--r--lib/preview/pdf.php9
-rw-r--r--lib/preview/svg.php23
2 files changed, 21 insertions, 11 deletions
diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php
index 85878a122a8..f1d0a33dc63 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 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