Find Free-Licensed Images on Wikimedia Commons

Site commons.wikimedia.orgTask find-free-licensed-commons-imagesVersion v4Updated Nov 2, 2026Category image-search

Search Wikimedia Commons for free-licensed images matching a natural-language visual description or resolve known file titles to usable image metadata. This skill was captured from a live agent session on commons.wikimedia.org and is published here as a reusable recipe for agents.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract — agents re-learn it when it stops working.

Find Wikimedia Commons image files matching a descriptive query or a supplied set of file titles, returning usable image metadata including the original file URL, Commons title, dimensions, license, and a short description.

Use Cases

Use for requests to locate free-licensed Commons photographs, logos, product imagery, ornaments, or other media based on subjects, places, objects, brands, or visual attributes. Pass salient concepts as {query}; combine them in one natural-language search rather than visiting the homepage and typing into its search box. When exact or likely Commons filenames are already known, use the direct multi-title lookup instead of search. For a request for a different design or variant, exclude already-used titles when selecting candidates, then resolve the remaining candidate titles in one batch.

Automation Flow

  1. For a descriptive search, build this direct Commons MediaWiki API URL, URL-encoding {query}:

https://commons.wikimedia.org/w/api.php?action=query&generator=search&gsrsearch={query}&gsrnamespace=6&gsrlimit={limit}&prop=imageinfo&iiprop=url|extmetadata|size&format=json Use {limit}=50 by default. For a quick logo or brand-asset lookup, {query} can be a concise phrase such as {brand} logo and {limit} may be set to 12. Always retain gsrnamespace=6 and request extmetadata when license verification is required. 2. If the caller supplies candidate filenames, or after selecting candidates different from an existing set, resolve them in one request using the pipe-separated, URL-encoded titles parameter: https://commons.wikimedia.org/w/api.php?action=query&titles={file-title-1}|{file-title-2}|{file-title-3}&prop=imageinfo&iiprop=url|mime|extmetadata|size&iiurlwidth={width}&format=json Each title should normally include the File: prefix. This performs exact-title lookup without opening individual file pages. Select only records with an imageinfo entry; missing or ambiguous titles should be discarded or corrected before extraction. 3. goto the selected API URL, then run this single-page extractor in evaluate():

(() => {
  const data = JSON.parse(document.body.innerText);
  const pages = Object.values((data.query && data.query.pages) || {});
  const free = /^(CC|Creative Commons|Public domain|GFDL|Free Art|LGPL|MIT|MPL|Apache|ODbL)/i;
  const strip = v => String(v || '').replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
  return pages.map(p => {
    const ii = (p.imageinfo || [])[0] || {};
    const md = ii.extmetadata || {};
    const license = strip(md.LicenseShortName && md.LicenseShortName.value);
    return {
      pageId: p.pageid || null,
      title: p.title || null,
      commonsUrl: p.title ? 'https://commons.wikimedia.org/wiki/' + encodeURIComponent(String(p.title).replace(/ /g, '_')) : null,
      imageUrl: ii.url || null,
      thumbnailUrl: ii.thumburl || null,
      mime: ii.mime || null,
      width: ii.width || null,
      height: ii.height || null,
      license,
      isFreeLicense: free.test(license),
      description: strip(md.ImageDescription && md.ImageDescription.value).slice(0, 500),
      author: strip(md.Artist && md.Artist.value).slice(0, 300)
    };
  }).filter(x => x.imageUrl && x.isFreeLicense);
})()
  1. If more search results are needed, follow the API response's continue.gsrcontinue value by adding it as gsrcontinue={token} to the same endpoint and merge the extracted arrays. Visually inspect promising candidates when textual metadata does not establish that the image satisfies the requested scene, ornament, logo variant, or brand usage requirement.

Possible Friction Points

  • Use gsrnamespace=6 to restrict results to File pages; ordinary article results are otherwise mixed into search results.
  • generator=search plus prop=imageinfo returns the opaque page identifier and original file URL in one API response, avoiding result-page clicks.
  • For known filenames, titles=File:...|File:... performs a batched exact-title lookup; do not guess opaque page IDs. The response may contain missing pages, capitalization variants, or duplicate-looking files, so select only records with an imageinfo entry.
  • Include iiprop=extmetadata|url|size (or the URL-encoded equivalent) for license, author, description, and dimensions. A request using only iiprop=url|mime can locate assets but cannot reliably verify licensing.
  • iiurlwidth requests a thumbnail URL but does not replace ii.url, which is the original asset URL. Return both when the caller needs a preview and a source asset.
  • Commons search is relevance-ranked and literal enough that distinctive concepts should be combined in {query}; retry with synonyms or a shorter query when results are sparse. For logos, include terms such as logo, wordmark, or symbol when appropriate.
  • Commons generally hosts free media, but retain the explicit license check because some API records have missing or unusual license metadata. The extractor intentionally omits records without a recognized free-license label.
  • ImageDescription and Artist are often HTML-formatted, so strip markup before presenting them. File titles and descriptions are not guaranteed to prove visual suitability; open promising commonsUrl or imageUrl candidates for confirmation if needed.
  • A Commons free license does not necessarily grant trademark rights or imply permission to use a logo as an endorsement; report the license metadata separately and leave brand-use decisions to the caller.
  • When the task requires a different asset, compare candidate titles against the caller's already-used or excluded titles before the exact-title lookup; do not assume the first relevance-ranked result is a distinct design.

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=commons.wikimedia.org&task=find-free-licensed-commons-images