Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

honour exif data for jpg thumbnails (aka, prevent thumbnails showing up sideways) #168

Merged

Conversation

joshuapaling
Copy link
Contributor

OK... this is a pretty important issue - no idea how this hasn't come up before, but about a hundred users have just signed up to a site I'm doing, and a decent percentage have sideways profile thumbnails!

The reason is this plugin doesn't honour an images exif orientation data, meaning that many photos, when uploaded, have their thumbnails sideways / upside down, etc.

This pull request fixes that - and doesn't change anything for images which are not JPG's with Exif Orientation data.

You probably know most of this, but I'll assume no knowledge just in case...
Some JPG's store "Exif" data, containing info like the images geolocation, and, importantly, orientation. If a camera is held eg. upside down to take a photo, the raw image is stored upside down, but the Exif Orientation data indicates that it should be rotated 180 degrees to be displayed.

Since most browsers interpret exif data, original images uploaded with this plugin will display fine - but the thumbnails made from them will not, because the exif data isn't transformed to the thumbnail. This pull request checks for exif orientation data in an image, and if it's present, adjusts the image appropriately (flips or rotates it). So, the thumbnail will be adjusted to display correctly, without the exif data.

I've followed this to get image orientation from exif data: http://www.impulseadventure.com/photo/exif-orientation.html

I've got no idea how you'd write tests for this, since the uploads themselves are mocked... if you've got ideas for how to auto-test, I'm happy to write the tests.

I have tested thoroughly, manually. I've tested images with exif orientations of 1, 3, 6 and 8, and I've tested for both php and imagick thumbnail methods. The other 4 orientation cases - 2, 4, 5, and 7 - are rare; they are when the image is flipped, and I don't have a camera that produces them. But I've coded carefully, and in any case, those cases can't be more broken than they already are!

If you want to test manually, here are some images with different exif orientation values (not sure if github will preserve the exif data, but you can make your own by just taking 4 photos with your iphone, rotating 90 degrees more for each one.

(UPDATE - as you can see, Github doesn't honour the exif data when displaying the images inline, but open each in a new tab and it will display correctly)

exif 6
exif6

exif 8
exif8

exif 3
exif3

exif 1
exif1

Signed-off-by: Joshua Paling joshua.paling@gmail.com

Signed-off-by: Joshua Paling <joshua.paling@gmail.com>
@josegonzalez
Copy link
Member

Tests fail.

@joshuapaling
Copy link
Contributor Author

OK, a couple of things... and I'm new to this travis CI stuff so bear with me...

  1. The tests do pass locally (see screenshot)

  2. Trying to find what's wrong with the Travis build, I noticed this message in all recent builds (both passing and failing builds):

"Cannot open file "/home/travis/build/josegonzalez/cakephp/cakephp/app/Plugin/Upload/Test/Case/AllUploadTest.php"."

So I'm not sure that the Cake Unit tests are being run at all?

  1. In terms of what's wrong with the built, all I can see is: "The command "./travis/script.sh" exited with 1." So I'm not sure how to figure out what specifically is wrong - looking at that file, it seems it's either Unit Test, PHPCS, or the FOC validate.sh - but the tests and phpcs passes, on my computer.

Can you help me figure out what is wrong?

screen shot 2013-10-02 at 9 47 30 am

josegonzalez added a commit that referenced this pull request Dec 13, 2013
honour exif data for jpg thumbnails (aka, prevent thumbnails showing up sideways)
@josegonzalez josegonzalez merged commit b990efb into FriendsOfCake:master Dec 13, 2013
@joshuapaling joshuapaling deleted the feature-honour-exif-data branch December 13, 2013 20:24
@joshuapaling
Copy link
Contributor Author

Thanks. Could you please update the version number?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants