Image: Exif Orientation Fix

Created on 26 May 2014  路  4Comments  路  Source: Intervention/image

This is a nice script just one thing that I have not found yet is the fix for Exif Orientation. Have you thought about this or am I just missing something? Thanks.

Most helpful comment

I added orientate method in e0d9c258.

// auto orientation
$img = Image::make('foo.jpg')->orientate();

By default orientation is ignored in both GD and Imagick now.

All 4 comments

I use something like this (modified based off code from the Laravel.io forums).

    try {

      $orientation = $image->exif('Orientation');

      if ( ! empty($orientation)) {

        switch ($orientation) {
          case 8:
            $image->rotate(90);
            break;
          case 3:
            $image->rotate(180);
            break;
          case 6:
            $image->rotate(-90);
            break;
        }

      }
    } catch (\Exception $e) {}

I would definitely be happy to see that in the core though, as it's a very common problem for photos uploaded from iOS devices.

I think the best solution would be to auto-orientate every image that is loaded.

The reasons why I am contained about this are:

  • Quality loss due to rotating
  • PHP must be compiled in with --enable-exif to read Exif informations

Imagick seems to auto-orientate images by default.

I added orientate method in e0d9c258.

// auto orientation
$img = Image::make('foo.jpg')->orientate();

By default orientation is ignored in both GD and Imagick now.

@olivervogel So is this orientate method going to turn the picture the correct way? Do you have a estimated time on when this feature will be available thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kivivuori picture kivivuori  路  8Comments

kamov picture kamov  路  6Comments

lasithg picture lasithg  路  3Comments

divdax picture divdax  路  7Comments

anil-kumar-pal picture anil-kumar-pal  路  6Comments