Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

iPad / iPhone Orientation (exif orientation tags) #190

Closed
AdrianSchneider opened this Issue · 23 comments
@AdrianSchneider

When an image is uploaded directly from an iPad or iPhone without going through a computer first, the image is not properly rotated. Usually the computer will apply transformations automatically upon import, but with a direct upload the image library will need to detect these tags and rotate the image automatically.

(sample code - http://php.net/manual/en/function.exif-read-data.php#110894)

Any thoughts?

@avalanche123

I think it would be a useful feature

@chadkoh

Yeah this is going to be a common thing going forward since more and more people are uploading directly "from camera" so to say. Kudos to @avalanche123 for replying quickly.

@romainneutron
Collaborator

Hello there,

some self promo here : I wrote http://github.com/romainneutron/MediaVorus earlier. It needs some love but it works rather pretty well for the moment. It's based on Phil Harvey's exiftool and it can extract such properties :

{
  "type": "Image",
  "raw_image": false,
  "multiple_layers": false,
  "width": 3264,
  "height": 2448,
  "channels": 3,
  "focal_length": 4.28,
  "color_depth": 8,
  "camera_model": "iPhone 4S",
  "flash_fired": false,
  "aperture": 2.4,
  "shutter_speed": 0.05,
  "orientation": 90,
  "creation_date": "2012:03:16 16:29:09",
  "hyperfocal_distance": 2.0773522348635,
  "ISO": 400,
  "light_value": 4.847996906555,
  "color_space": "RGB"
} 

There's a bit of documentation here http://mediavorus.readthedocs.org/en/latest/ but as I already said, it needs some love.

So, if anyone works on such PR in Imagine, I think could be awesome to incorporate a detection strategy based on exif PHP extension that could be replaced by another strategy.

@lmcd

+1 - I'm building a mobile app in Symfony leveraging Imagine via LiipImagineBundle. Whenever an Image is uploaded from the device's camera or photo library, it almost always ends up being upside down.

@romainneutron
Collaborator

Hey, guys, any of you ready to work on this ?

@lmcd

I threw this together as I needed this feature quite desperately:
https://github.com/lmcd/Imagine/commits/autorotate

@avalanche123
Owner

Your implementation looks great. I'm wondering if we should just autorotate automatically from Imagine::open directly? That way we wouldn't need autorotate method at all, and this would be a documented feature of Imagine.

@piotrgradzinski

+1
Is there any chance to add this quickly? I have the same problem as lmcd - photos uploaded from mobile devices.

@jdelaune

+1 Would love it to get auto-rotated on open.

@bamarni

What about Imagine::load()?

exif_read_data() can also work with binary data apparently (see http://stackoverflow.com/questions/5465665/extract-exif-data-from-an-image-blob-binary-string-in-php).

@romainneutron
Collaborator

Nice ! Thanks for the suggestion

@mumia

Is this fix stopped? I'm having the same problem with a lot of photos and this would just make it all go away.

@romainneutron
Collaborator

Hello @mumia ,

this feature request should not block you. The following code should solve it :

$exifData = exif_read_data('image.jpg');
switch($exifData['Orientation']) {
    case 8:
        $rotateVal = -90;
        break;
    case 3:
        $rotateVal = 180;
        break;
    case 6:
        $rotateVal = 90;
        break;
}
$image->rotate($rotateVal, $color);
@mumia

Yes, was just going to start looking into a fix for this problem.
Thanks for the code snippet. :)

@romainneutron
Collaborator

A fix is on its way in #222

@afoeder afoeder referenced this issue from a commit
@afoeder afoeder [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
a1aff1f
@afoeder afoeder referenced this issue from a commit
@afoeder afoeder [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
a4252ba
@demerzel3

+1 I'm writing an iphone app with symfony backend and it would really be awesome to have Imagine threat exif rotation transparently

@tirithen

I'm missing this feature as well for a website where users will upload images directly from their mobile devices.

@romainneutron
Collaborator

No need for a hack or a fix, you can use @frickelbruder filter until metadata support will be merged, see https://raw.github.com/frickelbruder/Imagine/develop/lib/Imagine/Filter/Advanced/CorrectExifRotation.php and #222

@tirithen

Thanks :)

@arjoe

+1 Any plans to merge @romainneutron PR? I would really like to see auto rotate support included.

@micronax

@romainneutron Great work! Thank you! Would also appreciate to merge it.

@romainneutron romainneutron referenced this issue from a commit in romainneutron/Imagine
@afoeder afoeder [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
55d4da5
@romainneutron romainneutron referenced this issue from a commit in romainneutron/Imagine
@afoeder afoeder [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
15918d1
@romainneutron romainneutron referenced this issue from a commit in romainneutron/Imagine
@afoeder afoeder [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
25c4c91
@romainneutron
Collaborator

I'm happy to close this issue, it's been fixed in 447b572

Feedback welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.