improve imagick error handling
This commit is contained in:
parent
5433a50461
commit
a014662c52
|
@ -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);
|
||||
|
||||
|
|
|
@ -16,17 +16,22 @@ if (extension_loaded('imagick')) {
|
|||
}
|
||||
|
||||
public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) {
|
||||
$svg = new \Imagick();
|
||||
$svg->setResolution($maxX, $maxY);
|
||||
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;
|
||||
$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
|
||||
|
|
Loading…
Reference in New Issue