summaryrefslogtreecommitdiffstats
path: root/lib/private/preview/pdf.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/preview/pdf.php')
-rw-r--r--lib/private/preview/pdf.php49
1 files changed, 28 insertions, 21 deletions
diff --git a/lib/private/preview/pdf.php b/lib/private/preview/pdf.php
index d390b4fc677..064a5a3b3d1 100644
--- a/lib/private/preview/pdf.php
+++ b/lib/private/preview/pdf.php
@@ -7,34 +7,41 @@
*/
namespace OC\Preview;
-if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
+use Imagick;
- class PDF extends Provider {
+if (extension_loaded('imagick')) {
- public function getMimeType() {
- return '/application\/pdf/';
- }
+ $checkImagick = new Imagick();
+
+ if(count($checkImagick->queryFormats('PDF')) === 1) {
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- $tmpPath = $fileview->toTmpFile($path);
+ class PDF extends Provider {
- //create imagick object from pdf
- try{
- $pdf = new \imagick($tmpPath . '[0]');
- $pdf->setImageFormat('jpg');
- } catch (\Exception $e) {
- \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
- return false;
+ public function getMimeType() {
+ return '/application\/pdf/';
}
- unlink($tmpPath);
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ $tmpPath = $fileview->toTmpFile($path);
+
+ //create imagick object from pdf
+ 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);
- //new image object
- $image = new \OC_Image($pdf);
- //check if image object is valid
- return $image->valid() ? $image : false;
+ //new image object
+ $image = new \OC_Image($pdf);
+ //check if image object is valid
+ return $image->valid() ? $image : false;
+ }
}
- }
- \OC\Preview::registerProvider('OC\Preview\PDF');
+ \OC\Preview::registerProvider('OC\Preview\PDF');
+ }
}