| @@ 41-67 (lines=27) @@ | ||
| 38 | /** |
|
| 39 | * {@inheritDoc} |
|
| 40 | */ |
|
| 41 | public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 42 | ||
| 43 | $tmpPath = $fileview->toTmpFile($path); |
|
| 44 | if (!$tmpPath) { |
|
| 45 | return false; |
|
| 46 | } |
|
| 47 | ||
| 48 | // Creates \Imagick object from bitmap or vector file |
|
| 49 | try { |
|
| 50 | $bp = $this->getResizedPreview($tmpPath, $maxX, $maxY); |
|
| 51 | } catch (\Exception $e) { |
|
| 52 | \OC::$server->getLogger()->logException($e, [ |
|
| 53 | 'message' => 'File: ' . $fileview->getAbsolutePath($path) . ' Imagick says:', |
|
| 54 | 'level' => ILogger::ERROR, |
|
| 55 | 'app' => 'core', |
|
| 56 | ]); |
|
| 57 | return false; |
|
| 58 | } |
|
| 59 | ||
| 60 | unlink($tmpPath); |
|
| 61 | ||
| 62 | //new bitmap image object |
|
| 63 | $image = new \OC_Image(); |
|
| 64 | $image->loadFromData($bp); |
|
| 65 | //check if image object is valid |
|
| 66 | return $image->valid() ? $image : false; |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Returns a preview of maxX times maxY dimensions in PNG format |
|
| @@ 51-77 (lines=27) @@ | ||
| 48 | /** |
|
| 49 | * {@inheritDoc} |
|
| 50 | */ |
|
| 51 | public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
| 52 | $tmpPath = $fileview->toTmpFile($path); |
|
| 53 | if (!$tmpPath) { |
|
| 54 | return false; |
|
| 55 | } |
|
| 56 | ||
| 57 | // Creates \Imagick object from the heic file |
|
| 58 | try { |
|
| 59 | $bp = $this->getResizedPreview($tmpPath, $maxX, $maxY); |
|
| 60 | $bp->setFormat('jpg'); |
|
| 61 | } catch (\Exception $e) { |
|
| 62 | \OC::$server->getLogger()->logException($e, [ |
|
| 63 | 'message' => 'File: ' . $fileview->getAbsolutePath($path) . ' Imagick says:', |
|
| 64 | 'level' => ILogger::ERROR, |
|
| 65 | 'app' => 'core', |
|
| 66 | ]); |
|
| 67 | return false; |
|
| 68 | } |
|
| 69 | ||
| 70 | unlink($tmpPath); |
|
| 71 | ||
| 72 | //new bitmap image object |
|
| 73 | $image = new \OC_Image(); |
|
| 74 | $image->loadFromData($bp); |
|
| 75 | //check if image object is valid |
|
| 76 | return $image->valid() ? $image : false; |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * Returns a preview of maxX times maxY dimensions in JPG format |
|