Jack000 / Expose

A simple static site generator for photoessays
MIT License
4.38k stars 255 forks source link

Auto-Orient to enable Exif rotated images to work #4

Closed artumi-richard closed 8 years ago

artumi-richard commented 8 years ago

I'm seeing failures to display Exif rotations coming through on the web pages. This commit adds a flag that will rotate the images based on the exif data, and fixes the problem. Interestingly the converted images appear correct when viewed alone, but as part of the web page they are not displayed correctly. I've found bugs in Webkit [1] and Mozilla[2] and I think they are ignoring it. It seems Exif rotation is not well supported anyway. [3]

[1] https://bugs.webkit.org/show_bug.cgi?id=19688 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=298619 [3] http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/

hutcheon commented 8 years ago

If you add the "-auto-orient" flag, the image is rotated properly, but the script needs more work to support the image rotation functionality.

The problem is not webkit or the browser cutting off the image. The problem is that the script calculates the height and width of the image before it rotates it. Then uses the pre-rotated values to generate the HTML template. So if you look at the HTML output for the rotated image, you will see the height property is all wrong -- that's what's cutting it off.

Best way I can think of to fix this is to grab the orientation when we pull the width and height (around line 392), and if it's 90/270 degrees, swap the width/height values. However, I couldn't get my imagemagick to tell me %[orientation] :(