Page MenuHomePhabricator

Mirrored EXIF rotations are not applied to thumbnails
Open, LowPublic

Description

EXIF allows 8 possible values for the Orientation field: 0°, 90°, 180°, 270°, and the same four for the mirror image of the original. The last four are not used often, but are supported to some degree by the browsers. (See http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/ for an overview of support.)

MediaWiki ignores mirrored rotations when generating thumbnails - the EXIF information is stripped, and the physical orientation is left unchanged. See [[commons:File:EXIF rotation 90 mirrored.jpg]] for an example (depending on the browser, you might need to open the image directly to see the correct position, or you might not see it at all - Chrome positions it correctly when viewed directly but not when viewed on a page).

Obviously this is Priority: No One Cares but filing it anyway for the sake of completeness.

Note that it seems that thumbor does not depend on metadata info of MediaWiki in order to do its rotation, so it should be possible to fix this relatively easily in thumbor for WMF purposes, without having to add yet another metadata aspect to the mediahandler classes.

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:53 AM
bzimport set Reference to bz73602.
bzimport added a subscriber: Unknown Object (MLST).

Here's what happens when you try images from the linked post. All images should look the same. Only 1, 3, 6 and 8 are correct.

EXIF test.png (1×631 px, 636 KB)

Change #1030610 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/core@master] [DNM] Add support for exif orientations that flip

https://gerrit.wikimedia.org/r/1030610

Experimented a bit, but still needs testcases, and i'm not sure about method naming etc yet.

Note that adding support for the other orientations, requires purging the db row's metadata, as the WxH are incorrect, which is somewhat problematic, as scanning all those 90 million rows for the effected files is going to be a pain.

For thumbor, the logic is here: https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/thumbor-plugins/+/refs/heads/master/wikimedia_thumbor/engine/imagemagick/imagemagick.py#443

Note: we don't have any of the mirroring info in our metadata tables, as we actively turn it into jepgRotation (with a value in degrees). So retroactively figuring this out for all images, requires reparsing all images, which is an known impossible issue...

@Tgr btw. Regarding our wikimania conversation, I was referring to T32961