Page MenuHomePhabricator

Is it possible to download smaller than full res image using Pywikibot?
Closed, ResolvedPublicFeature

Description

Is it possible to download smaller than full resolution Commons image using Pywikibot? Downloading a smaller file size would probably help to speed up my commons corruption checking task. However, I have yet to figure out how. Would this be something easily implemented?

Event Timeline

Is this related to FilePage.download() method?

Xqt triaged this task as Low priority.Mar 6 2020, 5:56 PM
Xqt changed the subtype of this task from "Task" to "Feature Request".

FilePage.get_file_url() have url_width / url_height parameter, but it doesn't download files but gives url and one needs manually download it.

https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.page.html#page.FilePage.get_file_url

FilePage.get_file_url() have url_width / url_height parameter, but it doesn't download files but gives url and one needs manually download it.

https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.page.html#page.FilePage.get_file_url

Good point. FilePage.download() could call this method to get the right url for downloading the file.

Change 924058 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Enable FilePage.download() to download thumbnails

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

Change 924058 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Enable FilePage.download() to download thumbnails

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

Thank you @Xqt ! I'd admittedly forgotten about this request but am glad that the feature has been added.

Thank you @Xqt!

Also just to document idea as I have used the FilePage.get_file_url() function. It would be useful that user could ask "thumbnail" from server and server would return something what is pregenerated. Currently when you need to set the random resolution then server most likely will generate the image and it will be slow compared something which comes directly from cache. It doesn't matter too much if you are downloading single image but if you are downloading 10M thumbnails the difference is so big that it defines if the task is possible or not.