From 9432e88d69ff5f1c988f7e34adbaf9e0a0276013 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 5 May 2014 20:37:17 +0200 Subject: [PATCH] Rotate thumbnail when encryption is enabled When a picture is encrypted, save it to a temporary file first so that the PHP function for rotation can access it as file. --- lib/thumbnail.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/thumbnail.php b/lib/thumbnail.php index 2d1b181da8..85c2afc1b5 100644 --- a/lib/thumbnail.php +++ b/lib/thumbnail.php @@ -58,15 +58,22 @@ public function __construct($imagePath, $user = null, $square = false) { private function create($imagePath, $square) { $galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/'; $dir = dirname($imagePath); - if (!$this->view->file_exists($imagePath)) { - return; + $fileInfo = $this->view->getFileInfo($imagePath); + if(!$fileInfo) { + return false; } if (!is_dir($galleryDir . $dir)) { mkdir($galleryDir . $dir, 0755, true); } - $local = $this->view->getLocalFile($imagePath); + $this->image = new \OCP\Image(); - $this->image->loadFromFile($local); + // check if file is encrypted + if($fileInfo['encrypted'] === true) { + $fileName = $this->view->toTmpFile($imagePath); + } else { + $fileName = $this->view->getLocalFile($imagePath); + } + $this->image->loadFromFile($fileName); if ($this->image->valid()) { $this->image->fixOrientation(); if ($square) {