mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-13 11:46:20 +00:00
Merge pull request #150 from beabee-communityrm/feat/jpeg-orientation
Add JPEG EXIF orientation rotation
This commit is contained in:
@@ -24,8 +24,43 @@ class ImageController implements ContentController
|
|||||||
case 17: $ext = 'ico';break; // ico
|
case 17: $ext = 'ico';break; // ico
|
||||||
case 18: $ext = 'webp';break; // webp
|
case 18: $ext = 'webp';break; // webp
|
||||||
|
|
||||||
case 2: //we clean up exif data of JPGs so GPS and other data is removed
|
case 2:
|
||||||
|
//we clean up exif data of JPGs so GPS and other data is removed
|
||||||
$res = imagecreatefromjpeg($tmpfile);
|
$res = imagecreatefromjpeg($tmpfile);
|
||||||
|
|
||||||
|
// rotate based on EXIF Orientation
|
||||||
|
$exif = exif_read_data($tmpfile);
|
||||||
|
if (!empty($exif['Orientation'])) {
|
||||||
|
switch ($exif['Orientation']) {
|
||||||
|
case 2:
|
||||||
|
imageflip($res, IMG_FLIP_HORIZONTAL);
|
||||||
|
case 1:
|
||||||
|
// Nothing to do
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
imageflip($res, IMG_FLIP_HORIZONTAL);
|
||||||
|
// Also rotate
|
||||||
|
case 3:
|
||||||
|
$res = imagerotate($res, 180, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
imageflip($res, IMG_FLIP_VERTICAL);
|
||||||
|
// Also rotate
|
||||||
|
case 6:
|
||||||
|
$res = imagerotate($res, -90, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
imageflip($res, IMG_FLIP_VERTICAL);
|
||||||
|
// Also rotate
|
||||||
|
case 8:
|
||||||
|
$res = imagerotate($res, 90, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
imagejpeg($res, $tmpfile, (defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
|
imagejpeg($res, $tmpfile, (defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
|
||||||
$ext = 'jpg';
|
$ext = 'jpg';
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ docker run -d -p 80:80 -e "TITLE=My own PictShare" -e "URL=http://localhost/" gh
|
|||||||
|
|
||||||
### Building it
|
### Building it
|
||||||
```bash
|
```bash
|
||||||
docker build -t pictshare .
|
docker build -t pictshare -f docker/Dockerfile .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Quick start
|
### Quick start
|
||||||
|
|||||||
Reference in New Issue
Block a user