@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | //.psd |
| 27 | 27 | class Photoshop extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType() { |
|
| 32 | - return '/application\/x-photoshop/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType() { |
|
| 32 | + return '/application\/x-photoshop/'; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class PNG extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType() { |
|
| 30 | - return '/image\/png/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType() { |
|
| 30 | + return '/image\/png/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -29,42 +29,42 @@ |
||
| 29 | 29 | |
| 30 | 30 | abstract class Image extends Provider { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * {@inheritDoc} |
|
| 34 | - */ |
|
| 35 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 36 | - //get fileinfo |
|
| 37 | - $fileInfo = $fileview->getFileInfo($path); |
|
| 38 | - if (!$fileInfo) { |
|
| 39 | - return false; |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * {@inheritDoc} |
|
| 34 | + */ |
|
| 35 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 36 | + //get fileinfo |
|
| 37 | + $fileInfo = $fileview->getFileInfo($path); |
|
| 38 | + if (!$fileInfo) { |
|
| 39 | + return false; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50); |
|
| 43 | - $size = $fileInfo->getSize(); |
|
| 42 | + $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50); |
|
| 43 | + $size = $fileInfo->getSize(); |
|
| 44 | 44 | |
| 45 | - if ($maxSizeForImages !== -1 && $size > ($maxSizeForImages * 1024 * 1024)) { |
|
| 46 | - return false; |
|
| 47 | - } |
|
| 45 | + if ($maxSizeForImages !== -1 && $size > ($maxSizeForImages * 1024 * 1024)) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $image = new \OC_Image(); |
|
| 49 | + $image = new \OC_Image(); |
|
| 50 | 50 | |
| 51 | - $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal(); |
|
| 52 | - if ($useTempFile) { |
|
| 53 | - $fileName = $fileview->toTmpFile($path); |
|
| 54 | - } else { |
|
| 55 | - $fileName = $fileview->getLocalFile($path); |
|
| 56 | - } |
|
| 57 | - $image->loadFromFile($fileName); |
|
| 58 | - $image->fixOrientation(); |
|
| 59 | - if ($useTempFile) { |
|
| 60 | - unlink($fileName); |
|
| 61 | - } |
|
| 62 | - if ($image->valid()) { |
|
| 63 | - $image->scaleDownToFit($maxX, $maxY); |
|
| 51 | + $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal(); |
|
| 52 | + if ($useTempFile) { |
|
| 53 | + $fileName = $fileview->toTmpFile($path); |
|
| 54 | + } else { |
|
| 55 | + $fileName = $fileview->getLocalFile($path); |
|
| 56 | + } |
|
| 57 | + $image->loadFromFile($fileName); |
|
| 58 | + $image->fixOrientation(); |
|
| 59 | + if ($useTempFile) { |
|
| 60 | + unlink($fileName); |
|
| 61 | + } |
|
| 62 | + if ($image->valid()) { |
|
| 63 | + $image->scaleDownToFit($maxX, $maxY); |
|
| 64 | 64 | |
| 65 | - return $image; |
|
| 66 | - } |
|
| 67 | - return false; |
|
| 68 | - } |
|
| 65 | + return $image; |
|
| 66 | + } |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | } |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | //.tiff |
| 27 | 27 | class TIFF extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType() { |
|
| 32 | - return '/image\/tiff/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType() { |
|
| 32 | + return '/image\/tiff/'; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | |
| 24 | 24 | //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx |
| 25 | 25 | class MSOffice2007 extends Office { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType() { |
|
| 30 | - return '/application\/vnd.openxmlformats-officedocument.*/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType() { |
|
| 30 | + return '/application\/vnd.openxmlformats-officedocument.*/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -26,89 +26,89 @@ |
||
| 26 | 26 | namespace OC\Preview; |
| 27 | 27 | |
| 28 | 28 | class Movie extends Provider { |
| 29 | - public static $avconvBinary; |
|
| 30 | - public static $ffmpegBinary; |
|
| 29 | + public static $avconvBinary; |
|
| 30 | + public static $ffmpegBinary; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * {@inheritDoc} |
|
| 34 | - */ |
|
| 35 | - public function getMimeType() { |
|
| 36 | - return '/video\/.*/'; |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * {@inheritDoc} |
|
| 34 | + */ |
|
| 35 | + public function getMimeType() { |
|
| 36 | + return '/video\/.*/'; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * {@inheritDoc} |
|
| 41 | - */ |
|
| 42 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 43 | - // TODO: use proc_open() and stream the source file ? |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + */ |
|
| 42 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 43 | + // TODO: use proc_open() and stream the source file ? |
|
| 44 | 44 | |
| 45 | - $fileInfo = $fileview->getFileInfo($path); |
|
| 46 | - $useFileDirectly = (!$fileInfo->isEncrypted() && !$fileInfo->isMounted()); |
|
| 45 | + $fileInfo = $fileview->getFileInfo($path); |
|
| 46 | + $useFileDirectly = (!$fileInfo->isEncrypted() && !$fileInfo->isMounted()); |
|
| 47 | 47 | |
| 48 | - if ($useFileDirectly) { |
|
| 49 | - $absPath = $fileview->getLocalFile($path); |
|
| 50 | - } else { |
|
| 51 | - $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 48 | + if ($useFileDirectly) { |
|
| 49 | + $absPath = $fileview->getLocalFile($path); |
|
| 50 | + } else { |
|
| 51 | + $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 52 | 52 | |
| 53 | - $handle = $fileview->fopen($path, 'rb'); |
|
| 53 | + $handle = $fileview->fopen($path, 'rb'); |
|
| 54 | 54 | |
| 55 | - // we better use 5MB (1024 * 1024 * 5 = 5242880) instead of 1MB. |
|
| 56 | - // in some cases 1MB was no enough to generate thumbnail |
|
| 57 | - $firstmb = stream_get_contents($handle, 5242880); |
|
| 58 | - file_put_contents($absPath, $firstmb); |
|
| 59 | - } |
|
| 55 | + // we better use 5MB (1024 * 1024 * 5 = 5242880) instead of 1MB. |
|
| 56 | + // in some cases 1MB was no enough to generate thumbnail |
|
| 57 | + $firstmb = stream_get_contents($handle, 5242880); |
|
| 58 | + file_put_contents($absPath, $firstmb); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $result = $this->generateThumbNail($maxX, $maxY, $absPath, 5); |
|
| 62 | - if ($result === false) { |
|
| 63 | - $result = $this->generateThumbNail($maxX, $maxY, $absPath, 1); |
|
| 64 | - if ($result === false) { |
|
| 65 | - $result = $this->generateThumbNail($maxX, $maxY, $absPath, 0); |
|
| 66 | - } |
|
| 67 | - } |
|
| 61 | + $result = $this->generateThumbNail($maxX, $maxY, $absPath, 5); |
|
| 62 | + if ($result === false) { |
|
| 63 | + $result = $this->generateThumbNail($maxX, $maxY, $absPath, 1); |
|
| 64 | + if ($result === false) { |
|
| 65 | + $result = $this->generateThumbNail($maxX, $maxY, $absPath, 0); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - if (!$useFileDirectly) { |
|
| 70 | - unlink($absPath); |
|
| 71 | - } |
|
| 69 | + if (!$useFileDirectly) { |
|
| 70 | + unlink($absPath); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $result; |
|
| 74 | - } |
|
| 73 | + return $result; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @param int $maxX |
|
| 78 | - * @param int $maxY |
|
| 79 | - * @param string $absPath |
|
| 80 | - * @param int $second |
|
| 81 | - * @return bool|\OCP\IImage |
|
| 82 | - */ |
|
| 83 | - private function generateThumbNail($maxX, $maxY, $absPath, $second) { |
|
| 84 | - $tmpPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 76 | + /** |
|
| 77 | + * @param int $maxX |
|
| 78 | + * @param int $maxY |
|
| 79 | + * @param string $absPath |
|
| 80 | + * @param int $second |
|
| 81 | + * @return bool|\OCP\IImage |
|
| 82 | + */ |
|
| 83 | + private function generateThumbNail($maxX, $maxY, $absPath, $second) { |
|
| 84 | + $tmpPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 85 | 85 | |
| 86 | - if (self::$avconvBinary) { |
|
| 87 | - $cmd = self::$avconvBinary . ' -y -ss ' . escapeshellarg($second) . |
|
| 88 | - ' -i ' . escapeshellarg($absPath) . |
|
| 89 | - ' -an -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . |
|
| 90 | - ' > /dev/null 2>&1'; |
|
| 91 | - } else { |
|
| 92 | - $cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) . |
|
| 93 | - ' -i ' . escapeshellarg($absPath) . |
|
| 94 | - ' -f mjpeg -vframes 1' . |
|
| 95 | - ' ' . escapeshellarg($tmpPath) . |
|
| 96 | - ' > /dev/null 2>&1'; |
|
| 97 | - } |
|
| 86 | + if (self::$avconvBinary) { |
|
| 87 | + $cmd = self::$avconvBinary . ' -y -ss ' . escapeshellarg($second) . |
|
| 88 | + ' -i ' . escapeshellarg($absPath) . |
|
| 89 | + ' -an -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . |
|
| 90 | + ' > /dev/null 2>&1'; |
|
| 91 | + } else { |
|
| 92 | + $cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) . |
|
| 93 | + ' -i ' . escapeshellarg($absPath) . |
|
| 94 | + ' -f mjpeg -vframes 1' . |
|
| 95 | + ' ' . escapeshellarg($tmpPath) . |
|
| 96 | + ' > /dev/null 2>&1'; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - exec($cmd, $output, $returnCode); |
|
| 99 | + exec($cmd, $output, $returnCode); |
|
| 100 | 100 | |
| 101 | - if ($returnCode === 0) { |
|
| 102 | - $image = new \OC_Image(); |
|
| 103 | - $image->loadFromFile($tmpPath); |
|
| 104 | - unlink($tmpPath); |
|
| 105 | - if ($image->valid()) { |
|
| 106 | - $image->scaleDownToFit($maxX, $maxY); |
|
| 101 | + if ($returnCode === 0) { |
|
| 102 | + $image = new \OC_Image(); |
|
| 103 | + $image->loadFromFile($tmpPath); |
|
| 104 | + unlink($tmpPath); |
|
| 105 | + if ($image->valid()) { |
|
| 106 | + $image->scaleDownToFit($maxX, $maxY); |
|
| 107 | 107 | |
| 108 | - return $image; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - unlink($tmpPath); |
|
| 112 | - return false; |
|
| 113 | - } |
|
| 108 | + return $image; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + unlink($tmpPath); |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 114 | 114 | } |
@@ -84,15 +84,15 @@ |
||
| 84 | 84 | $tmpPath = \OC::$server->getTempManager()->getTemporaryFile(); |
| 85 | 85 | |
| 86 | 86 | if (self::$avconvBinary) { |
| 87 | - $cmd = self::$avconvBinary . ' -y -ss ' . escapeshellarg($second) . |
|
| 88 | - ' -i ' . escapeshellarg($absPath) . |
|
| 89 | - ' -an -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . |
|
| 87 | + $cmd = self::$avconvBinary.' -y -ss '.escapeshellarg($second). |
|
| 88 | + ' -i '.escapeshellarg($absPath). |
|
| 89 | + ' -an -f mjpeg -vframes 1 -vsync 1 '.escapeshellarg($tmpPath). |
|
| 90 | 90 | ' > /dev/null 2>&1'; |
| 91 | 91 | } else { |
| 92 | - $cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) . |
|
| 93 | - ' -i ' . escapeshellarg($absPath) . |
|
| 94 | - ' -f mjpeg -vframes 1' . |
|
| 95 | - ' ' . escapeshellarg($tmpPath) . |
|
| 92 | + $cmd = self::$ffmpegBinary.' -y -ss '.escapeshellarg($second). |
|
| 93 | + ' -i '.escapeshellarg($absPath). |
|
| 94 | + ' -f mjpeg -vframes 1'. |
|
| 95 | + ' '.escapeshellarg($tmpPath). |
|
| 96 | 96 | ' > /dev/null 2>&1'; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | //.ai |
| 27 | 27 | class Illustrator extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType() { |
|
| 32 | - return '/application\/illustrator/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType() { |
|
| 32 | + return '/application\/illustrator/'; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class BMP extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType() { |
|
| 30 | - return '/image\/bmp/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType() { |
|
| 30 | + return '/image\/bmp/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | class PDF extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType() { |
|
| 32 | - return '/application\/pdf/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType() { |
|
| 32 | + return '/application\/pdf/'; |
|
| 33 | + } |
|
| 34 | 34 | } |