Page MenuHomePhabricator

How can I obtain the resolution or the image size from an SDC image via Pywikibot?
Closed, InvalidPublicFeature

Description

Feature summary: Get the image size or the resolution of a Wikimedia Commons image via SDC statements (Structured Data on Commons) using the Pywikibot library

Use case(s): We might enhance assigning images P18 statements in Wikidata, by ignoring "bad quality" images

Benefits: Have a better assignment of pictures in Wikidata using SDC P180 statements

See script https://github.com/geertivp/Pywikibot/blob/main/add_image_from_sdc.py for more details.

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

SDC does not seem to provide this information. It's accessible for files on all wikis using:

>>> import pywikibot
>>> commons = pywikibot.Site('commons:commons')
>>> file = pywikibot.FilePage(commons, 'Würfelzucker -- 2018 -- 3564.jpg')
>>> info = file.latest_file_info
>>> info.__dict__.keys()
dict_keys(['timestamp', 'user', 'size', 'width', 'height', 'comment', 'url', 'descriptionurl', 'descriptionshorturl', 'sha1', 'metadata', 'mime'])
>>> info['width'], info['height']
(5349, 3343)

Closing as invalid as this is not a bug report nor a feature request.