@@ -34,82 +34,82 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | abstract class Bitmap extends Provider { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * {@inheritDoc} |
|
| 39 | - */ |
|
| 40 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 41 | - |
|
| 42 | - $tmpPath = $fileview->toTmpFile($path); |
|
| 43 | - if (!$tmpPath) { |
|
| 44 | - return false; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // Creates \Imagick object from bitmap or vector file |
|
| 48 | - try { |
|
| 49 | - $bp = $this->getResizedPreview($tmpPath, $maxX, $maxY); |
|
| 50 | - } catch (\Exception $e) { |
|
| 51 | - \OCP\Util::writeLog('core', 'ImageMagick says: ' . $e->getmessage(), \OCP\Util::ERROR); |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - unlink($tmpPath); |
|
| 56 | - |
|
| 57 | - //new bitmap image object |
|
| 58 | - $image = new \OC_Image(); |
|
| 59 | - $image->loadFromData($bp); |
|
| 60 | - //check if image object is valid |
|
| 61 | - return $image->valid() ? $image : false; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Returns a preview of maxX times maxY dimensions in PNG format |
|
| 66 | - * |
|
| 67 | - * * The default resolution is already 72dpi, no need to change it for a bitmap output |
|
| 68 | - * * It's possible to have proper colour conversion using profileimage(). |
|
| 69 | - * ICC profiles are here: http://www.color.org/srgbprofiles.xalter |
|
| 70 | - * * It's possible to Gamma-correct an image via gammaImage() |
|
| 71 | - * |
|
| 72 | - * @param string $tmpPath the location of the file to convert |
|
| 73 | - * @param int $maxX |
|
| 74 | - * @param int $maxY |
|
| 75 | - * |
|
| 76 | - * @return \Imagick |
|
| 77 | - */ |
|
| 78 | - private function getResizedPreview($tmpPath, $maxX, $maxY) { |
|
| 79 | - $bp = new Imagick(); |
|
| 80 | - |
|
| 81 | - // Layer 0 contains either the bitmap or a flat representation of all vector layers |
|
| 82 | - $bp->readImage($tmpPath . '[0]'); |
|
| 83 | - |
|
| 84 | - $bp = $this->resize($bp, $maxX, $maxY); |
|
| 85 | - |
|
| 86 | - $bp->setImageFormat('png'); |
|
| 87 | - |
|
| 88 | - return $bp; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Returns a resized \Imagick object |
|
| 93 | - * |
|
| 94 | - * If you want to know more on the various methods available to resize an |
|
| 95 | - * image, check out this link : @link https://stackoverflow.com/questions/8517304/what-the-difference-of-sample-resample-scale-resize-adaptive-resize-thumbnail-im |
|
| 96 | - * |
|
| 97 | - * @param \Imagick $bp |
|
| 98 | - * @param int $maxX |
|
| 99 | - * @param int $maxY |
|
| 100 | - * |
|
| 101 | - * @return \Imagick |
|
| 102 | - */ |
|
| 103 | - private function resize($bp, $maxX, $maxY) { |
|
| 104 | - list($previewWidth, $previewHeight) = array_values($bp->getImageGeometry()); |
|
| 105 | - |
|
| 106 | - // We only need to resize a preview which doesn't fit in the maximum dimensions |
|
| 107 | - if ($previewWidth > $maxX || $previewHeight > $maxY) { |
|
| 108 | - // TODO: LANCZOS is the default filter, CATROM could bring similar results faster |
|
| 109 | - $bp->resizeImage($maxX, $maxY, imagick::FILTER_LANCZOS, 1, true); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - return $bp; |
|
| 113 | - } |
|
| 37 | + /** |
|
| 38 | + * {@inheritDoc} |
|
| 39 | + */ |
|
| 40 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 41 | + |
|
| 42 | + $tmpPath = $fileview->toTmpFile($path); |
|
| 43 | + if (!$tmpPath) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // Creates \Imagick object from bitmap or vector file |
|
| 48 | + try { |
|
| 49 | + $bp = $this->getResizedPreview($tmpPath, $maxX, $maxY); |
|
| 50 | + } catch (\Exception $e) { |
|
| 51 | + \OCP\Util::writeLog('core', 'ImageMagick says: ' . $e->getmessage(), \OCP\Util::ERROR); |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + unlink($tmpPath); |
|
| 56 | + |
|
| 57 | + //new bitmap image object |
|
| 58 | + $image = new \OC_Image(); |
|
| 59 | + $image->loadFromData($bp); |
|
| 60 | + //check if image object is valid |
|
| 61 | + return $image->valid() ? $image : false; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Returns a preview of maxX times maxY dimensions in PNG format |
|
| 66 | + * |
|
| 67 | + * * The default resolution is already 72dpi, no need to change it for a bitmap output |
|
| 68 | + * * It's possible to have proper colour conversion using profileimage(). |
|
| 69 | + * ICC profiles are here: http://www.color.org/srgbprofiles.xalter |
|
| 70 | + * * It's possible to Gamma-correct an image via gammaImage() |
|
| 71 | + * |
|
| 72 | + * @param string $tmpPath the location of the file to convert |
|
| 73 | + * @param int $maxX |
|
| 74 | + * @param int $maxY |
|
| 75 | + * |
|
| 76 | + * @return \Imagick |
|
| 77 | + */ |
|
| 78 | + private function getResizedPreview($tmpPath, $maxX, $maxY) { |
|
| 79 | + $bp = new Imagick(); |
|
| 80 | + |
|
| 81 | + // Layer 0 contains either the bitmap or a flat representation of all vector layers |
|
| 82 | + $bp->readImage($tmpPath . '[0]'); |
|
| 83 | + |
|
| 84 | + $bp = $this->resize($bp, $maxX, $maxY); |
|
| 85 | + |
|
| 86 | + $bp->setImageFormat('png'); |
|
| 87 | + |
|
| 88 | + return $bp; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Returns a resized \Imagick object |
|
| 93 | + * |
|
| 94 | + * If you want to know more on the various methods available to resize an |
|
| 95 | + * image, check out this link : @link https://stackoverflow.com/questions/8517304/what-the-difference-of-sample-resample-scale-resize-adaptive-resize-thumbnail-im |
|
| 96 | + * |
|
| 97 | + * @param \Imagick $bp |
|
| 98 | + * @param int $maxX |
|
| 99 | + * @param int $maxY |
|
| 100 | + * |
|
| 101 | + * @return \Imagick |
|
| 102 | + */ |
|
| 103 | + private function resize($bp, $maxX, $maxY) { |
|
| 104 | + list($previewWidth, $previewHeight) = array_values($bp->getImageGeometry()); |
|
| 105 | + |
|
| 106 | + // We only need to resize a preview which doesn't fit in the maximum dimensions |
|
| 107 | + if ($previewWidth > $maxX || $previewHeight > $maxY) { |
|
| 108 | + // TODO: LANCZOS is the default filter, CATROM could bring similar results faster |
|
| 109 | + $bp->resizeImage($maxX, $maxY, imagick::FILTER_LANCZOS, 1, true); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + return $bp; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | try { |
| 49 | 49 | $bp = $this->getResizedPreview($tmpPath, $maxX, $maxY); |
| 50 | 50 | } catch (\Exception $e) { |
| 51 | - \OCP\Util::writeLog('core', 'ImageMagick says: ' . $e->getmessage(), \OCP\Util::ERROR); |
|
| 51 | + \OCP\Util::writeLog('core', 'ImageMagick says: '.$e->getmessage(), \OCP\Util::ERROR); |
|
| 52 | 52 | return false; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $bp = new Imagick(); |
| 80 | 80 | |
| 81 | 81 | // Layer 0 contains either the bitmap or a flat representation of all vector layers |
| 82 | - $bp->readImage($tmpPath . '[0]'); |
|
| 82 | + $bp->readImage($tmpPath.'[0]'); |
|
| 83 | 83 | |
| 84 | 84 | $bp = $this->resize($bp, $maxX, $maxY); |
| 85 | 85 | |
@@ -26,80 +26,80 @@ |
||
| 26 | 26 | namespace OC\Preview; |
| 27 | 27 | |
| 28 | 28 | abstract class Office extends Provider { |
| 29 | - private $cmd; |
|
| 29 | + private $cmd; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * {@inheritDoc} |
|
| 33 | - */ |
|
| 34 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 35 | - $this->initCmd(); |
|
| 36 | - if (is_null($this->cmd)) { |
|
| 37 | - return false; |
|
| 38 | - } |
|
| 31 | + /** |
|
| 32 | + * {@inheritDoc} |
|
| 33 | + */ |
|
| 34 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 35 | + $this->initCmd(); |
|
| 36 | + if (is_null($this->cmd)) { |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $absPath = $fileview->toTmpFile($path); |
|
| 40 | + $absPath = $fileview->toTmpFile($path); |
|
| 41 | 41 | |
| 42 | - $tmpDir = \OC::$server->getTempManager()->getTempBaseDir(); |
|
| 42 | + $tmpDir = \OC::$server->getTempManager()->getTempBaseDir(); |
|
| 43 | 43 | |
| 44 | - $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir '; |
|
| 45 | - $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); |
|
| 44 | + $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir '; |
|
| 45 | + $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); |
|
| 46 | 46 | |
| 47 | - $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); |
|
| 47 | + $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); |
|
| 48 | 48 | |
| 49 | - shell_exec($exec); |
|
| 49 | + shell_exec($exec); |
|
| 50 | 50 | |
| 51 | - //create imagick object from pdf |
|
| 52 | - $pdfPreview = null; |
|
| 53 | - try { |
|
| 54 | - list($dirname, , , $filename) = array_values(pathinfo($absPath)); |
|
| 55 | - $pdfPreview = $dirname . '/' . $filename . '.pdf'; |
|
| 51 | + //create imagick object from pdf |
|
| 52 | + $pdfPreview = null; |
|
| 53 | + try { |
|
| 54 | + list($dirname, , , $filename) = array_values(pathinfo($absPath)); |
|
| 55 | + $pdfPreview = $dirname . '/' . $filename . '.pdf'; |
|
| 56 | 56 | |
| 57 | - $pdf = new \imagick($pdfPreview . '[0]'); |
|
| 58 | - $pdf->setImageFormat('jpg'); |
|
| 59 | - } catch (\Exception $e) { |
|
| 60 | - unlink($absPath); |
|
| 61 | - unlink($pdfPreview); |
|
| 62 | - \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR); |
|
| 63 | - return false; |
|
| 64 | - } |
|
| 57 | + $pdf = new \imagick($pdfPreview . '[0]'); |
|
| 58 | + $pdf->setImageFormat('jpg'); |
|
| 59 | + } catch (\Exception $e) { |
|
| 60 | + unlink($absPath); |
|
| 61 | + unlink($pdfPreview); |
|
| 62 | + \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR); |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $image = new \OC_Image(); |
|
| 67 | - $image->loadFromData($pdf); |
|
| 66 | + $image = new \OC_Image(); |
|
| 67 | + $image->loadFromData($pdf); |
|
| 68 | 68 | |
| 69 | - unlink($absPath); |
|
| 70 | - unlink($pdfPreview); |
|
| 69 | + unlink($absPath); |
|
| 70 | + unlink($pdfPreview); |
|
| 71 | 71 | |
| 72 | - if ($image->valid()) { |
|
| 73 | - $image->scaleDownToFit($maxX, $maxY); |
|
| 72 | + if ($image->valid()) { |
|
| 73 | + $image->scaleDownToFit($maxX, $maxY); |
|
| 74 | 74 | |
| 75 | - return $image; |
|
| 76 | - } |
|
| 77 | - return false; |
|
| 75 | + return $image; |
|
| 76 | + } |
|
| 77 | + return false; |
|
| 78 | 78 | |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - private function initCmd() { |
|
| 82 | - $cmd = ''; |
|
| 81 | + private function initCmd() { |
|
| 82 | + $cmd = ''; |
|
| 83 | 83 | |
| 84 | - $libreOfficePath = \OC::$server->getConfig()->getSystemValue('preview_libreoffice_path', null); |
|
| 85 | - if (is_string($libreOfficePath)) { |
|
| 86 | - $cmd = $libreOfficePath; |
|
| 87 | - } |
|
| 84 | + $libreOfficePath = \OC::$server->getConfig()->getSystemValue('preview_libreoffice_path', null); |
|
| 85 | + if (is_string($libreOfficePath)) { |
|
| 86 | + $cmd = $libreOfficePath; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $whichLibreOffice = shell_exec('command -v libreoffice'); |
|
| 90 | - if ($cmd === '' && !empty($whichLibreOffice)) { |
|
| 91 | - $cmd = 'libreoffice'; |
|
| 92 | - } |
|
| 89 | + $whichLibreOffice = shell_exec('command -v libreoffice'); |
|
| 90 | + if ($cmd === '' && !empty($whichLibreOffice)) { |
|
| 91 | + $cmd = 'libreoffice'; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $whichOpenOffice = shell_exec('command -v openoffice'); |
|
| 95 | - if ($cmd === '' && !empty($whichOpenOffice)) { |
|
| 96 | - $cmd = 'openoffice'; |
|
| 97 | - } |
|
| 94 | + $whichOpenOffice = shell_exec('command -v openoffice'); |
|
| 95 | + if ($cmd === '' && !empty($whichOpenOffice)) { |
|
| 96 | + $cmd = 'openoffice'; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - if ($cmd === '') { |
|
| 100 | - $cmd = null; |
|
| 101 | - } |
|
| 99 | + if ($cmd === '') { |
|
| 100 | + $cmd = null; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - $this->cmd = $cmd; |
|
| 104 | - } |
|
| 103 | + $this->cmd = $cmd; |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -41,20 +41,20 @@ |
||
| 41 | 41 | |
| 42 | 42 | $tmpDir = \OC::$server->getTempManager()->getTempBaseDir(); |
| 43 | 43 | |
| 44 | - $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir '; |
|
| 44 | + $defaultParameters = ' -env:UserInstallation=file://'.escapeshellarg($tmpDir.'/owncloud-'.\OC_Util::getInstanceId().'/').' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir '; |
|
| 45 | 45 | $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); |
| 46 | 46 | |
| 47 | - $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); |
|
| 47 | + $exec = $this->cmd.$clParameters.escapeshellarg($tmpDir).' '.escapeshellarg($absPath); |
|
| 48 | 48 | |
| 49 | 49 | shell_exec($exec); |
| 50 | 50 | |
| 51 | 51 | //create imagick object from pdf |
| 52 | 52 | $pdfPreview = null; |
| 53 | 53 | try { |
| 54 | - list($dirname, , , $filename) = array_values(pathinfo($absPath)); |
|
| 55 | - $pdfPreview = $dirname . '/' . $filename . '.pdf'; |
|
| 54 | + list($dirname,,, $filename) = array_values(pathinfo($absPath)); |
|
| 55 | + $pdfPreview = $dirname.'/'.$filename.'.pdf'; |
|
| 56 | 56 | |
| 57 | - $pdf = new \imagick($pdfPreview . '[0]'); |
|
| 57 | + $pdf = new \imagick($pdfPreview.'[0]'); |
|
| 58 | 58 | $pdf->setImageFormat('jpg'); |
| 59 | 59 | } catch (\Exception $e) { |
| 60 | 60 | unlink($absPath); |
@@ -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 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class XBitmap extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType() { |
|
| 30 | - return '/image\/x-xbitmap/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType() { |
|
| 30 | + return '/image\/x-xbitmap/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class GIF extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType() { |
|
| 30 | - return '/image\/gif/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType() { |
|
| 30 | + return '/image\/gif/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -22,11 +22,11 @@ |
||
| 22 | 22 | namespace OC\Preview; |
| 23 | 23 | |
| 24 | 24 | class MarkDown extends TXT { |
| 25 | - /** |
|
| 26 | - * {@inheritDoc} |
|
| 27 | - */ |
|
| 28 | - public function getMimeType() { |
|
| 29 | - return '/text\/(x-)?markdown/'; |
|
| 30 | - } |
|
| 25 | + /** |
|
| 26 | + * {@inheritDoc} |
|
| 27 | + */ |
|
| 28 | + public function getMimeType() { |
|
| 29 | + return '/text\/(x-)?markdown/'; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | } |