summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-06-02 19:06:46 +0200
committerVincent Petry <pvince81@owncloud.com>2014-06-02 19:06:46 +0200
commitc88c0b9a13231478c626296d78aac7c1f66d87d9 (patch)
treedf78daa3a8d266860e2ae84da46193f1a6db0126 /core
parente8ec81110d65c8fd7b3876db4f798b714fde9c9d (diff)
parentd0548b92c05e715dbcc7775be1be1d39b9981b6c (diff)
downloadnextcloud-server-c88c0b9a13231478c626296d78aac7c1f66d87d9.tar.gz
nextcloud-server-c88c0b9a13231478c626296d78aac7c1f66d87d9.zip
Merge pull request #8812 from josh4trunks/avatar_rotate
Automatically Rotate Avatar based on exif data
Diffstat (limited to 'core')
-rw-r--r--core/avatar/controller.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/avatar/controller.php b/core/avatar/controller.php
index 06efbec3f3c..03eb9da1dc5 100644
--- a/core/avatar/controller.php
+++ b/core/avatar/controller.php
@@ -46,7 +46,12 @@ class Controller {
if (isset($_POST['path'])) {
$path = stripslashes($_POST['path']);
$view = new \OC\Files\View('/'.$user.'/files');
- $newAvatar = $view->file_get_contents($path);
+ $fileInfo = $view->getFileInfo($path);
+ if($fileInfo['encrypted'] === true) {
+ $fileName = $view->toTmpFile($path);
+ } else {
+ $fileName = $view->getLocalFile($path);
+ }
} elseif (!empty($_FILES)) {
$files = $_FILES['files'];
if (
@@ -54,7 +59,9 @@ class Controller {
is_uploaded_file($files['tmp_name'][0]) &&
!\OC\Files\Filesystem::isFileBlacklisted($files['tmp_name'][0])
) {
- $newAvatar = file_get_contents($files['tmp_name'][0]);
+ \OC\Cache::set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200);
+ $view = new \OC\Files\View('/'.$user.'/cache');
+ $fileName = $view->getLocalFile('avatar_upload');
unlink($files['tmp_name'][0]);
}
} else {
@@ -64,11 +71,9 @@ class Controller {
}
try {
- $avatar = new \OC_Avatar($user);
- $avatar->set($newAvatar);
- \OC_JSON::success();
- } catch (\OC\NotSquareException $e) {
- $image = new \OC_Image($newAvatar);
+ $image = new \OC_Image();
+ $image->loadFromFile($fileName);
+ $image->fixOrientation();
if ($image->valid()) {
\OC\Cache::set('tmpavatar', $image->data(), 7200);