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":
However, the URLs refer to the full-size images. How can I access the smaller versions programmatically?
Well, you need to change your query from
list=allimages
toprop=imageinfo
and instead use the list as a generator. Then for the imageinfo you can specifyiiurlwidth
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