iPhones 4 and up store images in landscape mode and use EXIF data to provide proper rotation when viewed. This is a bit quirky as not all desktop browsers provide fixes, or they may not be streamlined.

We've experienced issues with mobile user's uploading photos taken by the iOS camera and they always rendering in landscape mode. I discovered: http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling... as a resource and began on a patch to implement correction of the image's orientation based on the EXIF data, if the EXIF implementation exists on the server.

Patch incoming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman’s picture

Status: Active » Needs review
FileSize
1.77 KB

Patch for EXIF Orientation correction.

mglaman’s picture

FileSize
2.07 MB

Attached example screenshot. Left screen is the image displayed in Drupal's <img>tag, the right if the image viewed alone inside of Chrome. This was taken with an iPhone.

Status: Needs review » Needs work

The last submitted patch, 1: 2290011-exif-orientation-correction-1.patch, failed testing.

mglaman’s picture

mglaman’s picture

The last submitted patch, 1: 2290011-exif-orientation-correction-1.patch, failed testing.

mglaman’s picture

Status: Needs work » Needs review

Forgot patch.

mglaman’s picture

Updated patch to provide missing EXIF key when test bot runs.

mglaman’s picture

Linking discussion in Panopoly queue about this patch.

drclaw’s picture

Great patch! I noticed, however, that the mappings of the orientations to the degrees might be off slightly? At least if the diagram in http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling... is correct. Attached patch fixes the issue.

EXIF Orientations Map

mglaman’s picture

It's highly likely, drclaw, that I got it wrong. I get a bit dyslexic with these things. I just know I got it to work right for basic "hey, turn this thing clockwise" :)

drclaw’s picture

No worries! =)

Dave Reid’s picture

Status: Needs review » Closed (won't fix)

I think this is out of scope for File Entity. That said, I love this feature and I would totally encourage this to be uploaded as a separate module since this doesn't need to depend on File entity at all. You could use hook_file_presave() to run the processing and it will work for *all* files uploaded to Drupal.

drclaw’s picture

Ha. Yes that is a very good point indeed! We could also implement a custom flip function as well to get all orientations implemented.

mglaman’s picture

For the Googler's who fell upon this page: Here is the project's page: https://www.drupal.org/project/exif_orientation