Wikimedia Commons Pdf logo

Wikimedia Commons Pdf

Community
fuzheado
wikimedia-commons-pdf

Work with PDF and DjVu documents on Wikimedia Commons — multi-page document model, page selection for thumbnails (page1- prefix), page dimensions, uploading large documents, Wikisource proofread integration, OCR text extraction, document metadata (pagecount, PDF version), and editing/versioning multi-page files

Overview

Publisherfuzheado
RepositoryWikipedia-AI-Skills
Skill namewikimedia-commons-pdf
Stars
27
Forks
10
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by fuzheado on GitHub. Read the source before you install it.

Installation

Install the Wikimedia Commons Pdf AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-commons-pdf
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fuzheado/Wikipedia-AI-Skills.git /tmp/Wikipedia-AI-Skills
mkdir -p .claude/skills
cp -r /tmp/Wikipedia-AI-Skills/.claude/skills/wikimedia-commons-pdf .claude/skills/wikimedia-commons-pdf
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Wikimedia Commons Pdf in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Wikimedia Commons Pdf on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Wikimedia Commons Pdf is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

⚠️ User-Agent required: All curl and code examples in this skill access Wikimedia APIs. Requests without a descriptive User-Agent header will be blocked with HTTP 403 or 429. See the wikimedia-api-access skill for the correct format and rate-limiting patterns.


1. PDF/DjVu on Commons: Document Model

PDF and DjVu files on Commons are treated as multi-page documents, not single images. This affects everything from how metadata is reported to how thumbnails work.

Key Differences from Image Files

AspectImage (JPEG, PNG, etc.)Document (PDF, DjVu)
API width/heightNative pixel dimensionsPage dimensions (typically the first page)
mediatypeBITMAP, DRAWINGOFFICE or TEXT
pagecountNot presentPresent — number of pages
ThumbnailOne per fileOne per page — page selector prefix in URL
ResolutionFixed (native pixels)Unlimited (page renders at any size)

Format Comparison

FormatMIME TypeTypical UseNotes
PDFapplication/pdfScanned books, documents, formsMost common document format on Commons
DjVuimage/vnd.djvuScanned books, especially on WikisourceBetter compression for scanned text pages

💡 DjVu is less common on Commons overall, but very common on Wikisource because of its superior compression for scanned text (black-and-white or limited-color pages). Many older Wikisource works use DjVu.

API: Checking If a File Is a Document

python
import requests

resp = requests.get("https://commons.wikimedia.org/w/api.php", params={
    "action": "query",
    "prop": "imageinfo",
    "iiprop": "size|mime|metadata|mediatype",
    "titles": "File:The Three Hostages (1924).pdf",
    "format": "json",
}, headers={"User-Agent": "MyBot/1.0 (user@example.com)"})

page = next(iter(resp.json()["query"]["pages"].values()))
info = page.get("imageinfo", [{}])[0]

print(f"MIME:       {info.get('mime')}")
print(f"Mediatype:  {info.get('mediatype')}")
print(f"Dimensions: {info.get('width')}×{info.get('height')} (page 1)")
print(f"File size:  {info.get('size')} bytes")

# Extract pagecount from metadata
for meta in info.get("metadata", []):
    if meta["name"] == "pagecount":
        print(f"Pages:      {meta['value']}")

2. Page Selection and Thumbnails

Thumb URL Pattern for Documents

Document thumbnails include a page selector in the URL:

https://upload.wikimedia.org/wikipedia/commons/thumb/{hash}/{filename}/page{N}-{width}px-{filename}.jpg

Where {N} is the 1-indexed page number.

Real example (PDF, page 1, 960px):

https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/PDF_metadata.pdf/page1-960px-PDF_metadata.pdf.jpg

Requesting Thumbnails via the Action API

Use iiurlwidth to request a thumbnail — it defaults to page 1:

python
resp = requests.get("https://commons.wikimedia.org/w/api.php", params={
    "action": "query",
    "prop": "imageinfo",
    "iiprop": "url|thumbmime",
    "iiurlwidth": 800,
    "titles": "File:PDF_metadata.pdf",
    "format": "json",
}, timeout=30, headers={"User-Agent": "MyBot/1.0 (user@example.com)"})

info = next(iter(resp.json()["query"]["pages"].values()))["imageinfo"][0]
print(f"Page 1 thumb: {info['thumburl']}")     # → .../page1-960px-....jpg
print(f"Thumb MIME:   {info['thumbmime']}")    # → image/jpeg
print(f"Dimensions:   {info['thumbwidth']}×{info['thumbheight']}")

Selecting a Specific Page via iiurlparam

To get a thumbnail for a different page, use iiurlparam:

python
resp = requests.get("https://commons.wikimedia.org/w/api.php", params={
    "action": "query",
    "prop": "imageinfo",
    "iiprop": "url|thumbmime",
    "iiurlwidth": 800,
    "iiurlparam": "page3",          # request page 3
    "titles": "File:100-page-document.pdf",
    "format": "json",
}, timeout=30, headers={"User-Agent": "MyBot/1.0 (user@example.com)"})

💡 iiurlparam syntax: page{N} where N is the 1-indexed page number. This works for both PDF and DjVu.

⚠️ An out-of-range page is CLAMPED, not refused. Measured 2026-09-15: iiurlparam=page189 on a 188-page document returned page 188 — the identical file, byte for byte (136,458 bytes both times) — with no error and no warning. Clamp to the pagecount from imageinfo; never probe for a 404 to find the last page.

📐 The delivered image is not the size you asked for. The same request (iiurlwidth=1024) returned a thumburl the API described as 1024 × 1405, and Wikimedia served 960 × 1317 — widths are bucketed. Lay out from the image's own naturalWidth/naturalHeight; do not trust thumbwidth/thumbheight.

🚫 A page render is served only at certain widths — and the wrong width is not a 404. Measured 2026-09-15 on a PDF (File:PDF metadata.pdf) and a DjVu (File:Mozart Sonate (manuscript).djvu), with identical results, so this is a property of document rendering and not of one file:

widths
served120 · 250 · 330 · 500 · 960 · 1280
HTTP 400 + an HTML error page70 · 150 · 200 · 320 · 400 · 640 · 700 · 800 · 1024 · 1200

A 400 here is not a harmless miss. Chrome will not hand an HTML response to an <img> at all — the request fails as net::ERR_BLOCKED_BY_ORB and you get a blank page with no visible reason. It is not MediaWiki's image-thumbnail width set: 150/200/400/640/800/1024 are standard image widths and every one of them fails for documents. And note the top of the range: 960 is a ceiling — asking 1200 or 2000 returns 960.

So build a document's width ladder from the served list, and let iiurlwidth be your friend: the API rewrites a requested width to a legal one (asked 320 → got 330; asked 700 → 960). If you need one specific width, ask the API for it rather than constructing the URL yourself.

🧹 thumburl carries query junk (?utm_source=commons.wikimedia.org…). Strip everything from ? before caching, comparing or de-duplicating thumb URLs.

Constructing Thumb URLs for Arbitrary Pages

If you have the page 1 thumb URL, you can construct URLs for other pages by replacing the page number:

python
import re

page1_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Doc.pdf/page1-960px-Doc.pdf.jpg"
page_n_url = re.sub(r"/page\d+-", f"/page{page_number}-", page1_url)

⚠️ Don't construct — ask. This pattern works most of the time, and when it fails it fails with an opaque 400 rather than a fallback. Measured 2026-09-15 on a 50 MB, 188-page PDF (File:The excavations at Dura-Europos … The Palace of Dux Ripae and the Dolicheneum.pdf):

requestresult
hand-built upload.wikimedia.org/…/page1-1024px-….jpg — also tried for pages 94, 188 and 189, and with the filename unencoded, lossy-page1-, and 800pxHTTP 400 — a Wikimedia error page, text/html, ~2 KB
the same pages via prop=imageinfo&iiurlwidth=1024&iiurlparam=page{N} → the thumburl it returns200, image/jpeg

The returned URL was on thumb.wikimedia.org, not upload.wikimedia.org. Both hosts serve a cached thumbnail (a small PDF's page 1 came back byte-identical from each), but a host you guess may not be the one that can render the page. So: take the URL from the API response — its host, hash directories and percent-encoding are already correct — and keep this regex only for adjusting the page number within a URL the API gave you.

Thumbnail Format

Document page thumbnails are always JPEG (thumbmime: image/jpeg), regardless of whether the source is PDF or DjVu.


3. Page Dimensions Across a Document

What the API Reports

The width and height fields in prop=imageinfo report the dimensions of page 1 only. In a multi-page document, different pages may have different dimensions.

Getting Dimensions for All Pages

Commons does not expose per-page dimensions directly through the Action API. To get them:

Option 1: Parse the PDF metadata (for locally accessible files)

bash
# Using pdfinfo (part of poppler-utils)
pdfinfo document.pdf | grep -E "Pages|Page size"

Option 2: Render each page and check dimensions (slow but works via API)

python
for page_num in range(1, pagecount + 1):
    resp = requests.get("https://commons.wikimedia.org/w/api.php", params={
        "action": "query",
        "prop": "imageinfo",
        "iiprop": "size",
        "iiurlwidth": 100,  # small width to minimize bandwidth
        "iiurlparam": f"page{page_num}",
        "titles": "File:Doc.pdf",
        "format": "json",
    }, timeout=30, headers={"User-Agent": "MyBot/1.0 (user@example.com)"})
    info = next(iter(resp.json()["query"]["pages"].values()))["imageinfo"][0]
    print(f"Page {page_num}: {info['thumbwidth']}×{info['thumbheight']}")

💡 This is slow for large documents. Consider fetching the PDF locally and using PyPDF2 or similar to extract per-page dimensions.

DjVu vs PDF Page Structure

AspectPDFDjVu
Page dimensionsCan vary per pageCan vary per page
CompressionPer-page content streamsSingle file with layered pages
Page count metadatapdf_pagecount fieldpagecount field
Page numbering1-indexed1-indexed

4. Uploading Documents

Allowed Formats

FormatAccepted?Notes
PDF✅Most common document format
DjVu✅Preferred for Wikisource scanned texts
EPUB❌Not supported by Commons
MOBI❌Not supported
DOC/DOCX❌Not supported — convert to PDF first
ODT❌Not supported — convert to PDF first

Converting to PDF for Upload

bash
# Convert DOCX to PDF (LibreOffice)
libreoffice --headless --convert-to pdf input.docx

# Convert EPUB to PDF
pandoc input.epub -o output.pdf

# Combine multiple images into a PDF
convert page-*.jpg combined.pdf

File Size Considerations

  • Documents can be hundreds of megabytes (scanned books at high resolution)
  • Commons has a per-file size limit (typically 100 MB for standard upload, larger may require chunked upload or special handling)
  • DjVu tends to be smaller than PDF for scanned text pages

Upload Tools

ToolBest For
UploadWizardSingle documents, step-by-step metadata entry
PattypanBatch uploads with spreadsheet-based metadata
Action API (action=upload)Automated uploads with authentication

⚠️ video2commons does NOT handle PDF or DjVu. Use UploadWizard, Pattypan, or direct API upload instead.

Converting DjVu ↔ PDF

bash
# DjVu → PDF
ddjvu -format=pdf input.djvu output.pdf

# PDF → DjVu (for Wikisource — better compression for text pages)
pdf2djvu input.pdf -o output.djvu  # preserves OCR text layer when present

5. Wikisource Integration (Critical)

The primary use of PDF and DjVu files on Commons is as backing documents for Wikisource — the free-content digital library.

The Proofread Page Workflow

Wikisource uses a proofread workflow where:

  1. A scanned document (PDF or DjVu) is uploaded to Commons
  2. Wikisource creates one Page: namespace page per document page
  3. Editors proofread the OCR text against the scan image
  4. Once validated, pages are transcluded into the final work in the main namespace

Linking Pattern

The linking between a Commons document and its Wikisource pages uses the {{ProofreadPage}} template:

https://en.wikisource.org/w/index.php?title=Page:Book_Title.djvu/1

Each Page:Namespace page (NS 104 on Wikisource) contains:

  • The OCR text extracted from that page
  • The scan image of that page (referenced to the Commons file)
  • Proofreading status (Proofread, Problematic, Validated)

Checking If a Document Is Used on Wikisource

Use prop=globalusage to check if a document is linked to Wikisource:

python
resp = requests.get("https://commons.wikimedia.org/w/api.php", params={
    "action": "query",
    "prop": "globalusage",
    "titles": "File:My_Document.pdf",
    "format": "json",
}, timeout=30, headers={"User-Agent": "MyBot/1.0 (user@example.com)"})

usage = next(iter(resp.json()["query"]["pages"].values())).get("globalusage", [])
wikisource_usage = [u for u in usage if "wikisource" in u.get("wiki", "")]
print(f"Used on {len(wikisource_usage)} Wikisource(s)")

Marking Documents for Wikisource

TemplatePurpose
{{PDF}}General PDF marker
{{DjVu}}General DjVu marker
{{Book}}Full book description template (author, title, year, pages)
{{ProofreadPage}}Links the file to its Wikisource work

🔗 Detailed Wikisource workflow: See the wikisource skill for complete coverage of the proofread page lifecycle, including validation levels, progress tracking, and transclusion.


6. Document Metadata

PDF-Specific Metadata

The Action API iiprop=metadata returns PDF-specific fields:

python
resp = requests.get("https://commons.wikimedia.org/w/api.php", params={
    "action": "query",
    "prop": "imageinfo",
    "iiprop": "metadata",
    "titles": "File:Document.pdf",
    "format": "json",
}, timeout=30, headers={"User-Agent": "MyBot/1.0 (user@example.com)"})

info = next(iter(resp.json()["query"]["pages"].values()))["imageinfo"][0]
for meta in info.get("metadata", []):
    print(f"{meta['name']}: {meta['value']}")

Common PDF metadata fields:

FieldTypeExample
pagecountInteger324
pdf_versionString1.7
pdf_encryptedBooleanfalse
pdf_createdTimestamp2020-01-15T10:30:00
pdf_modifiedTimestamp2020-06-01T14:22:00
pdf_pagecountIntegerSame as pagecount
pdf_has_xfaBooleanWhether the PDF uses XFA forms

DjVu-Specific Metadata

DjVu files expose different metadata:

FieldDescription
pagecountNumber of pages
djvu_page_widthWidth of each page (comma-separated if varying)
djvu_page_heightHeight of each page
djvu_resolutionScan resolution in DPI

Shared Metadata

Both PDF and DjVu may expose:

  • playtime_seconds — Not standard for documents, but may be populated for some PDF/DjVu files
  • mediatype — OFFICE or TEXT

7. OCR and Text Extraction

Commons runs automatic OCR on uploaded PDF and DjVu files using Tesseract.

How OCR Works

  1. File is uploaded to Commons
  2. The OCR pipeline detects the language(s) present
  3. Tesseract extracts text from each page
  4. The extracted text is made available on the corresponding Wikisource Page: namespace

Checking OCR Status

OCR status is not directly exposed by the Commons API. To check if OCR has been run:

  • Check the file's Wikisource Page: namespace entries — if they contain text, OCR ran
  • Manual validation: the {{PDFOCR}} template on the file page indicates OCR was applied

When OCR May Fail

SituationResult
Language not supported by TesseractNo OCR
Handwritten textPoor quality or no OCR
Image-only pages (no text)No OCR
Very poor scan qualityGarbled OCR
Scan resolution too low (<150 DPI)Poor OCR quality

Uploading a Text Layer

If the automatic OCR is insufficient, you can upload a PDF or DjVu that already contains an embedded text layer. Tools like pdf2djvu preserve existing text layers during conversion.


8. PDF/DjVu-Specific Templates and Categories

Templates

TemplateUsage
{{PDF}}Marks file as a PDF, adds to Category:PDF files
{{DjVu}}Marks file as a DjVu, adds to Category:DjVu files
{{Book}}Descriptive template for multi-page documents with title, author, year, pages, source, and other bibliographic fields
{{Proofread}}Links to the corresponding Wikisource work
{{PDFOCR}}Indicates OCR text has been extracted
{{Scanned}}Marks as a scanned document (as opposed to born-digital PDF)

Category Hierarchy

Category:PDF files
├── PDF files by language
│   ├── PDF files in English
│   ├── PDF files in French
│   └── ...
├── PDF files by topic
│   ├── PDF books
│   ├── PDF journals
│   └── ...
└── PDF files by size

Category:DjVu files
├── DjVu files by language
├── DjVu files by topic
└── DjVu files by size

Category:Scan pages
├── Proofread
├── Not proofread
└── Problematic

9. Editing and Versioning Documents

Uploading a New Version

The same action=upload pattern used for images applies to documents:

python
with open("corrected-ocr.pdf", "rb") as f:
    resp = SESSION.post("https://commons.wikimedia.org/w/api.php", data={
        "action": "upload",
        "filename": "Existing_Document.pdf",
        "comment": "Replaced page 47 scan, fixed OCR layer",
        "token": csrf_token,
        "format": "json",
    }, files={"file": f})

🔗 Authentication setup: See wikimedia-auth-oauth for bot passwords and CSRF token handling.

⚠️ Page Range Replacement

Commons does not support partial page replacement within a document. To replace a single page:

  1. Download the full document locally
  2. Extract all pages
  3. Replace the specific page(s)
  4. Recombine and re-upload the entire document
bash
# Extract all pages from PDF
pdfseparate -f 1 -l 500 input.pdf page-%d.pdf

# Replace page 47
# ... edit page-47.pdf ...

# Recombine
pdfunite page-*.pdf output.pdf

# Upload output.pdf as new version of the original

Replacing DjVu with PDF (or Vice Versa)

If you need to change the format of an existing document (e.g., replace a DjVu with a better-quality PDF), you cannot "re-upload" to the same filename with a different MIME type. You must:

  1. Upload the new file as a new filename (e.g., Document (PDF).pdf)
  2. Update Wikisource Page: namespace links to point to the new file
  3. Request deletion of the old file (if appropriate)

File History for Documents

All previous versions of a document are retained in the file history, just like images:

python
resp = SESSION.get("https://commons.wikimedia.org/w/api.php", params={
    "action": "query",
    "prop": "imageinfo",
    "iiprop": "url|timestamp|user|size|comment",
    "titles": "File:Document.pdf",
    "format": "json",
})

Each archived version includes a timestamped URL to download that version.


Related Skills

SkillRelevance
wikimedia-api-accessUser-Agent, rate limiting, error handling
wikimedia-commonsFile search, categories, upload basics
wikimedia-commons-thumbnailsDocument page rendering, thumb URL scheme, thumbmime
wikisourceWikisource proofread workflow, Page: namespace, transclusion, EPUB export
wikimedia-auth-oauthAuthentication for uploading new document versions

Frequently asked questions

What does the Wikimedia Commons Pdf AI skill do?

Work with PDF and DjVu documents on Wikimedia Commons — multi-page document model, page selection for thumbnails (page1- prefix), page dimensions, uploading large documents, Wikisource proofread integration, OCR text extraction, document metadata (pagecount, PDF version), and editing/versioning multi-page files

Why use Wikimedia Commons Pdf on TypingMind?

Because you install it once and use it with any model. Wikimedia Commons Pdf is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Wikimedia Commons Pdf in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-commons-pdf. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Wikimedia Commons Pdf?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Wikimedia Commons Pdf?

As many as you like. As long as a model supports skills, you can use Wikimedia Commons Pdf with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Wikimedia Commons Pdf AI skill free?

Yes. It is published on GitHub by fuzheado under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇