Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2020-07-26 20:39:29 +0300
committerPhie <phie@phie.ovh>2020-07-26 20:41:11 +0300
commitba1d12bdfdff7f1c954e8459b4a64813fb2a0b29 (patch)
treed97506b6ae5a326b276a94f957b7c78d26c164e7
parentf9712795ab02b732dacdb093e33e2cae16ff5b5c (diff)
rotate preview with exif data
-rwxr-xr-xlib/Controller/NoteController.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php
index 5ca9528..88b9b32 100755
--- a/lib/Controller/NoteController.php
+++ b/lib/Controller/NoteController.php
@@ -866,9 +866,27 @@ public function getOpusEncoder(){
$width = 400*$ratio;
$height = 400;
}
- $src = imagecreatefromstring(file_get_contents($fn));
+ $srcFile = file_get_contents($fn);
+ $src = imagecreatefromstring($srcFile);
+
+
$dst = imagecreatetruecolor($width,$height);
imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]);
+ $exif = exif_read_data($fn, 0, true);
+ if(!empty($exif)){
+ $orientation = $exif['IFD0']['Orientation'];
+ switch($orientation) {
+ case 3:
+ $dst = imagerotate($dst, 180, 0);
+ break;
+ case 6:
+ $dst = imagerotate($dst, -90, 0);
+ break;
+ case 8:
+ $dst = imagerotate($dst, 90, 0);
+ break;
+ }
+ }
imagedestroy($src);
$fileOut = $data->newFile("preview_".$_FILES['media']['name'][0].".jpg");
array_push($files, "data/"."preview_".$_FILES['media']['name'][0].".jpg");