Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff.txt | 633 bytes | drclaw |
#10 | 2290011-exif-orientation-correction-10.patch | 1.91 KB | drclaw |
#10 | EXIF_Orientations.jpg | 19.22 KB | drclaw |
#8 | 2290011-exif-orientation-correction-8.patch | 1.9 KB | mglaman |
#1 | 2290011-exif-orientation-correction-1.patch | 1.77 KB | mglaman |
Comments
Comment #1
mglamanPatch for EXIF Orientation correction.
Comment #2
mglamanAttached 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.Comment #4
mglaman1: 2290011-exif-orientation-correction-1.patch queued for re-testing.
Comment #5
mglamanComment #7
mglamanForgot patch.
Comment #8
mglamanUpdated patch to provide missing EXIF key when test bot runs.
Comment #9
mglamanLinking discussion in Panopoly queue about this patch.
Comment #10
drclaw CreditAttribution: drclaw commentedGreat 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.
Comment #11
mglamanIt'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" :)
Comment #12
drclaw CreditAttribution: drclaw commentedNo worries! =)
Comment #13
Dave ReidI 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.
Comment #14
drclaw CreditAttribution: drclaw commentedHa. Yes that is a very good point indeed! We could also implement a custom flip function as well to get all orientations implemented.
Comment #15
mglamanFor the Googler's who fell upon this page: Here is the project's page: https://www.drupal.org/project/exif_orientation