Under review

JPEG EXIF Rotation

olivier 6 days ago • updated 6 days ago 4

Hi, first of all thank you for this great software!

I noticed that the way EXIF rotations are handled is not perfect.

I created a gallery with the files from https://github.com/recurser/exif-orientation-examples.

Regarding the thumbnails (tested in Firefox and Chromium):

- on my installation (2017.09.25), the number 1,3,6,8 are correctly rotated

- on demo.filerun.co (2017.09.25), they are all correctly rotated

However, when I open them for a preview, only the number 1 (without rotation) is correctly displayed (on demo and on my installation).

I digged further, and I think that demo.filerun.co correctly rotates the previews because it uses the ImageMagick "convert" binary.

See https://stackoverflow.com/questions/20600800/js-client-side-exif-orientation-rotate-and-mirror-jpeg-images for possible solutions.

Under review

ImageMagick/GraphicsMagick is almost a requirement with FileRun. It used to be fine, in the old days, to use PHP's own image manipulation capability to generate resized previews of the image files. However, in 2017, most photography files are getting really large, and PHP's performance in comparison with a dedicated app such as IM/GM is ridiculously poor. We keep it for convenience, even though we know there are limitations, more like a workaround before the admin enables IM/GM.
We'll still take it into consideration and if there is more interest shown, we'll include the orientation correction when not using IM/GM. But my hopes are not very high.

I totally understand your point (I am now using ImageMagick on my installation :-).

With ImageMagick activated, all the thumbnails are fine.

However there are still some issues:

- on a shared folder gallery: the fullscreen view is not rotated at all (expect on firefox when I manually add `image-orientation: from-image`)

- on my own gallery, the preview is not rotated

- on my own gallery, the zoomed view is not rotated

This answer seems like a nice trick: https://stackoverflow.com/a/46013100/3207406 (PHP + CSS cooperation)

When the size of the preview is not much smaller than the actual file, FileRun serves the actual file, without doing a resize, as it's much quicker to transfer it to the browser than processing the file on the server side. Unfortunately browsers don't yet support auto-orientation of images loaded inside pages (except Firefox with its "image-orientation: from-image").

The linked solution is elegant, but it is not that easy to implement inside FileRun, as FileRun doesn't make server requests other than for the image itself, when the user double-clicks it, and that would mean to have FileRun extract the EXIF information on all image files, before listing a folder contents, an action which would take too much server resources and will make large folders take long to list.

If the other browsers implement "image-orientation: from-image" we'll make FileRun use it. It currently can't, as the attribute doesn't cover "background-image" as FileRun uses, but only "img" tags.

We haven't ignored the orientation aspect, just didn't yet find the best solution for handle it. We'll try harder ;)

I haven't thought about the performance issue.

A possible solution would be to turn it within the browser, with a small JS script: https://stackoverflow.com/a/32490603/3207406 (for this to work, you will probably need to load it on js and then set the background-image attribute, like this: https://stackoverflow.com/a/34642144/3207406)

I would recommend setting a `data-exif-orientation` attribute based on the result of the call and let the CSS rotate the background using `transform` depending on this `data-exif-orientation` attribute.