2013-05-10 01:59:16 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2013-05-17 14:00:32 +04:00
|
|
|
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
|
2013-05-10 01:59:16 +04:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
2013-05-28 13:59:20 +04:00
|
|
|
if (extension_loaded('imagick')){
|
2013-05-10 01:59:16 +04:00
|
|
|
|
2013-05-28 13:59:20 +04:00
|
|
|
class OC_Preview_PDF extends OC_Preview_Provider{
|
|
|
|
|
|
|
|
public function getMimeType(){
|
|
|
|
return '/application\/pdf/';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
|
|
|
$tmppath = $fileview->toTmpFile($path);
|
2013-05-10 01:59:16 +04:00
|
|
|
|
2013-05-28 13:59:20 +04:00
|
|
|
//create imagick object from pdf
|
|
|
|
$pdf = new imagick($tmppath . '[0]');
|
|
|
|
$pdf->setImageFormat('jpg');
|
2013-05-17 21:08:16 +04:00
|
|
|
|
2013-05-28 13:59:20 +04:00
|
|
|
unlink($tmppath);
|
2013-05-10 01:59:16 +04:00
|
|
|
|
2013-05-28 13:59:20 +04:00
|
|
|
//new image object
|
|
|
|
$image = new \OC_Image($pdf);
|
|
|
|
//check if image object is valid
|
|
|
|
if (!$image->valid()) return false;
|
|
|
|
|
|
|
|
return $image;
|
|
|
|
}
|
2013-05-10 01:59:16 +04:00
|
|
|
}
|
|
|
|
|
2013-05-28 13:59:20 +04:00
|
|
|
OC_Preview::registerProvider('OC_Preview_PDF');
|
|
|
|
}
|