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.

CommentFileSizeAuthor
#10 interdiff.txt633 bytesdrclaw
#10 2290011-exif-orientation-correction-10.patch1.91 KBdrclaw
PASSED: [[SimpleTest]]: [MySQL] 877 pass(es). View
#10 EXIF_Orientations.jpg19.22 KBdrclaw
#8 2290011-exif-orientation-correction-8.patch1.9 KBmglaman
PASSED: [[SimpleTest]]: [MySQL] 877 pass(es). View
#1 2290011-exif-orientation-correction-1.patch1.77 KBmglaman
FAILED: [[SimpleTest]]: [MySQL] 877 pass(es), 0 fail(s), and 60 exception(s). View
#2 iOS EXIF Issue.png2.07 MBmglaman
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

mglaman’s picture

Status: Active » Needs review
FileSize
1.77 KB
FAILED: [[SimpleTest]]: [MySQL] 877 pass(es), 0 fail(s), and 60 exception(s). View

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

FileSize
1.9 KB
PASSED: [[SimpleTest]]: [MySQL] 877 pass(es). View

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

FileSize
19.22 KB
1.91 KB
PASSED: [[SimpleTest]]: [MySQL] 877 pass(es). View
633 bytes

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