Skip to content

Commit

Permalink
Add Orientate Option to read exif and orientate automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradie Tilley committed Sep 1, 2021
1 parent 9ed9c0e commit 86d2fa5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion classes/Resizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Exception;
use Event;
use File;
use Log;
use Intervention\Image\ImageManagerStatic as Image;
use Validator;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -294,7 +295,19 @@ public function initResource()
throw new \Exception('Image file does not exist (not found)');
}

$this->im = $this->original = Image::make($this->image);
// Auto Rotate based on exif data
if ($this->options['orientate'] ?? false) {
try {
$this->im = $this->original = Image::make($this->image)->orientate();
} catch (\Throwable $e) {
Log::debug('Failed to fix orientation for image ' . $this->getImagePath() . ' (Is PHP compiled with `--enable-exif`?)');
}
}

// If no orientation requested (or orientation failed)
if (empty($this->im)) {
$this->im = $this->original = Image::make($this->image);
}
} catch (\Exception $e) {
if ($this->allowDefaultImage) {
$this->setFormatCache([]);
Expand Down
4 changes: 3 additions & 1 deletion updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@
2.2.4:
- Fix exception when directory doesn't exist during cache clear
2.2.5:
- Fix regeneration of permalink images that previously defaulted to 404 image
- Fix regeneration of permalink images that previously defaulted to 404 image
2.3.0:
- Add Orientate Option to read exif and orientate automatically

0 comments on commit 86d2fa5

Please sign in to comment.