Page MenuHomePhabricator

MediaWiki's imageheight calculation is sometimes off by 1
Open, Needs TriagePublic

Description

Consider: https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/SR_Technics_hangar_at_Zurich_International_Airport.jpg/800px-SR_Technics_hangar_at_Zurich_International_Airport.jpg

MediaWiki (according to the image description page and height attribute on https://commons.wikimedia.org/wiki/File:SR_Technics_hangar_at_Zurich_International_Airport.jpg ) thinks this image is 800x458. However the actual dimensions of the image are 800x457

Somewhere in the calculation there is some incorrect rounding or other off by 1 error.

Expected behaviour

  • MediaWiki knows the correct dimensions of thumbnails.

See also T318486#9990608

Event Timeline

Possibly related, but i think different - this is about MW being consistent about the thumbnail's dimensions, whatever they are

The result is 457.7614537px (800px*(2960px/5173px)), that seems to rounded and results in 458.

At least all places seems using same values, so the fix could be simple.

api - https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&titles=File:SR_Technics_hangar_at_Zurich_International_Airport.jpg&iiurlwidth=800&iiprop=url
file page
parser when adding the <img> tag

I guess we should verify if other image scaling methods round the same way

Recently I've made the tool able to not reject images that just had size improvement with https://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-ImageAnnotator.js&diff=prev&oldid=887093691 and noow I see this issue, I'm not sure how that's related to my changes or how I can share the logic.

I think however we should go for something better for the tool, that's why I've suggested a rewrite or integration of it to WikibaseMediaInfo, https://meta.wikimedia.org/wiki/Community_Wishlist/Wishes/Rewrite_ImageAnnotator_or_integrate_it_into_MediaWiki_WikibaseMediaInfo