Page MenuHomePhabricator

Browsers apply EXIF orientation, but MediaWiki applies EXIF rotation as well, causing incorrect orientation in UploadWizard and Special:Upload previews
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Upload a picture to Commons, being very careful not to get it upside down.

What happens?:
Success! As you see we succeeded!

20230603T123346.jpg (229×621 px, 22 KB)

But...

We still failed in reality:

20230603T123031.jpg (693×654 px, 80 KB)

What should have happened instead?:

Either both pictures you see above should be right-side up.

Or both pictures should be upside-down.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

https://commons.wikimedia.org/wiki/File:Aquino_Assassination_Plaque_151054_01.jpg

Maybe fixing this bug would reduce rotation requests.

Event Timeline

Aklapper renamed this task from Commons uploads upside-down despite right-side up previews to EXIF orientation ignored on Commons upload despite correct preview of photo.Oct 23 2023, 10:48 AM

Thx, @Jidanni! The rotation seems to be made by SteinsplitterBot
I came across a different rotation issue - on mobile UploadWizard displays the orientation incorrectly in Upload step , but upon uploading, the orientation is correct, which is an opposite to the issue you've reported. I'll do more testing to see whether these issues are similar.

This is an issue with the image specifying tiff and exif rotation fields. The UploadWizard only looks at one (TIFF ?), but some systems look at both (so 180+180 == 360). This might have something to do with the one denoting how the image is STORED, vs the other denoting how the image should be DISPLAYED ? Not entirely sure, the whole orientation thing of images is rife with historic problems. There are literally entire blogposts dedicated to how much of a mess orientation is.

Traditionally, exif orientation didn't use to be respected by browsers. But it seems that this has changed in 2020, and apparently the default for all browsers was flipped to respect orientation ???

Not sure if there is a JS level test to see what you need to do now.

https://github.com/w3c/csswg-drafts/issues/4666
https://mcc.id.au/2020/image-orientation/

So it seems the default flipped in early 2020 and had fully stabilized early 2021. 94% of users should have exif rotation automatically.

I suggest we gate the rotation functionality on the result of CSS.supports("image-orientation", "from-image"). If supported, then JS rotation should no longer be needed.
We can then remove the entire rotation library in another year (or two).

I've made a quick patch for core that does this, which should be enough for some testing with demopatch, but will need some cleanup before it can be merged

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

[mediawiki/core@master] [DNM] upload: No preview rotation if browser already does so

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

Special:ListFiles is also wacky:

No, that thumb is of the archived file, which indeed is upside down. The special page shows historic actions, not current records.

I see. If this box is checked,

20231116T172320.jpg (109×246 px, 4 KB)

one only sees the oldest version.

If it is unchecked one only sees the latest version.

It seems that box should be better worded.

TheDJ renamed this task from EXIF orientation ignored on Commons upload despite correct preview of photo to Browsers apply EXIF orientation, but MediaWiki applies EXIF rotation as well, causing incorrect orientation in UploadWizard and Special:Upload previews.Mar 13 2024, 12:42 PM

I just ran into this problem while uploading a few files, one of which was https://commons.wikimedia.org/wiki/File:Ankeng_LRT_tram_1.jpg

In my case, UploadWizard showed the wrong orientation, but the preview on Commons ended up being correct.

In the past, this has led me to believe that Commons doesn't support EXIF rotation, and so I would find software to perform lossless rotation before uploading images to Commons, even though in hindsight it was probably unnecessary. This might have confused a good number of others as well, since I took my photos on an iPhone, and the iOS camera app apparently makes use of EXIF rotation.

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

[mediawiki/extensions/UploadWizard@master] Do not apply preview rotation if the browser supports rotation

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

Change #1030606 merged by jenkins-bot:

[mediawiki/extensions/UploadWizard@master] Do not apply preview rotation if the browser supports rotation

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

Change #971323 merged by jenkins-bot:

[mediawiki/core@master] Special:Upload: No preview rotation if browser already does so

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

TheDJ claimed this task.
TheDJ removed a project: Wikimedia-Hackathon-2024.

Should be fixed after deploy later this week.