MediaWiki API: Download smaller versions of images

253 views Asked by At

I want to download all images matching a certain criteria from the Wikimedia commons.

This API call gives me the image URLs of 5 images matching the search term "Programming":

http://commons.wikimedia.org/w/api.php?action=query&list=allimages&ailimit=5&aifrom=Programming&aiprop=dimensions|url

However, the URLs refer to the full-size images. How can I access the smaller versions programmatically?

1

There are 1 answers

0
Ainali On BEST ANSWER

Well, you need to change your query from list=allimages to prop=imageinfo and instead use the list as a generator. Then for the imageinfo you can specify iiurlwidth as desired.

Example with width 500: http://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=url%7Cdimensions&iiurlwidth=500&titles=Programming&generator=allimages