ocr-documents
Skill1 starsChanged 3 months agoMITView on GitHub
Use when the user has an image, screenshot, or scanned document and wants the text extracted — via Tesseract or EasyOCR — including preprocessing low-quality scans, pulling text with bounding boxes, OCR'ing a PDF page, or handling multi-language/handwritten input.
- Installs packages
In this repository58 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- api-test-suiteSkill
- ascii-artSkill
- caddy-reverse-proxySkill
- changelog-generatorSkill
- color-palette-generatorSkill
- cron-taskSkill
- csv-toolkitSkill
- discord-bot-buildSkill
- docker-umbrellaSkill
- dotfiles-manageSkill
- email-sendSkill
- env-config-managerSkill
- excalidraw-diagramSkill
- file-organizerSkill
- forgejo-self-hostSkill
- frontend-design-toolkitSkill
- generate-dockerfileSkill
- gif-searchSkill
- git-backupSkill
- github-actions-ciSkill
- hallmark-readmeSkill
- http-api-testerSkill
- invoice-generatorSkill
- json-formatterSkill
- log-analyzerSkill
- markdown-linterSkill
- markdown-to-pdfSkill
- markdown-to-slidesSkill
- mcp-server-buildSkill
- media-id-mappingSkill
- movie-catalogue-siteSkill
- movie-night-calendarSkill
- ntfy-notifierSkill
- ollama-localSkill
- openapi-generatorSkill
- password-generatorSkill
- pdf-extractSkill
- portfolio-upkeepSkill
- qr-code-generatorSkill
- regex-testerSkill
- resume-builderSkill
- rss-monitorSkill
- searxng-self-hostSkill
- skill-publishSkill
- skill-registry-catalogSkill
- skills-portfolio-scaffoldSkill
- snippet-managerSkill
- sqlite-dashboardSkill
- streaming-provider-embedsSkill
- tailscale-deploySkill
- telegram-bot-buildSkill
- tmdb-metadataSkill
- uptime-kuma-self-hostSkill
- watchlist-syncSkill
- webhook-receiverSkill
- youtube-transcriptSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 141
Check image quality — if low resolution or poor contrast, preprocess
- Distinctive: line 142
Run Tesseract for printed text, EasyOCR for handwriting/complex layouts
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ocr-documents
Overview
Extract text from images, screenshots, and scanned documents using Tesseract OCR and EasyOCR. The agent handles image preprocessing, OCR execution, and text cleanup.
When to Use
- The user has a screenshot or image containing text they want to extract.
- The user has a scanned document that needs to be converted to editable text.
- The user says "read the text in this image", "OCR this scan", or "extract text from screenshot".
Prerequisites
# Tesseract (recommended for most use cases)
pip install pytesseract pillow
# System package:
# Linux: apt install tesseract-ocr
# macOS: brew install tesseract
# Windows: https://github.com/UB-Mannheim/tesseract/wiki
# EasyOCR (alternative, better for handwriting/complex layouts)
pip install easyocrBasic OCR
Tesseract (fast, reliable for printed text)
import pytesseract
from PIL import Image
def ocr_image(image_path: str, lang: str = "eng") -> str:
img = Image.open(image_path)
return pytesseract.image_to_string(img, lang=lang)EasyOCR (better for complex layouts, handwriting)
import easyocr
reader = easyocr.Reader(['en'])
def ocr_image_easyocr(image_path: str) -> str:
results = reader.readtext(image_path)
return "\n".join([r[1] for r in results])Image Preprocessing
OCR accuracy depends heavily on image quality. Preprocess for better results:
from PIL import Image, ImageEnhance, ImageFilter
import pytesseract
def ocr_with_preprocessing(image_path: str) -> str:
img = Image.open(image_path)
# Convert to grayscale
img = img.convert('L')
# Increase contrast
enhancer = ImageEnhance.Contrast(img)
img = enhancer.enhance(2.0)
# Sharpen
img = img.filter(ImageFilter.SHARPEN)
# Upscale small images
if img.width < 1000:
ratio = 1000 / img.width
img = img.resize((int(img.width * ratio), int(img.height * ratio)))
return pytesseract.image_to_string(img)OCR with Bounding Boxes
import pytesseract
from PIL import Image, ImageDraw
def ocr_with_boxes(image_path: str, output_path: str = "annotated.png"):
img = Image.open(image_path)
data = pytesseract.image_to_data(img, output_type=pytesseract.Output.DICT)
draw = ImageDraw.Draw(img)
for i in range(len(data["text"])):
if int(data["conf"][i]) > 60: # confidence threshold
x, y, w, h = data["left"][i], data["top"][i], data["width"][i], data["height"][i]
draw.rectangle([x, y, x + w, y + h], outline="red", width=2)
img.save(output_path)
return [data["text"][i] for i in range(len(data["text"])) if int(data["conf"][i]) > 60]PDF Page OCR
import fitz # pymupdf
import pytesseract
from PIL import Image
import io
def ocr_pdf_page(pdf_path: str, page_num: int = 0, dpi: int = 300) -> str:
doc = fitz.open(pdf_path)
page = doc[page_num]
pix = page.get_pixmap(dpi=dpi)
img = Image.open(io.BytesIO(pix.tobytes("png")))
return pytesseract.image_to_string(img)Multi-language OCR
# Install language packs:
# Linux: apt install tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-spa
# Then:
text = pytesseract.image_to_string(img, lang='eng+fra+deu')Workflow
- Identify the image or document to OCR
- Check image quality — if low resolution or poor contrast, preprocess
- Run Tesseract for printed text, EasyOCR for handwriting/complex layouts
- Clean up the output (remove stray characters, fix common OCR errors)
- Return the extracted text
Common OCR Errors and Fixes
| Error | Cause | Fix |
| Empty output | Image too small | Upscale to 1000px+ width |
| Garbled text | Low contrast | Convert to grayscale + enhance contrast |
| Missing text | Dark background | Invert colors: ImageOps.invert(img) |
| Wrong characters | Similar-looking chars (0/O, 1/l) | Post-process with regex replacements |
| Slow processing | High DPI | Use 300 DPI (sufficient for most text) |
Common Pitfalls
- Tesseract path not found on Windows. Unlike Linux/macOS, the
tesseractbinary isn't on PATH by default. Set it explicitly:pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'. - Handwriting comes back garbled. Tesseract is trained on printed text and performs poorly on handwriting. Switch to EasyOCR or TrOCR instead of trying to tune Tesseract further.
- Rotated pages produce nonsense text. Tesseract assumes horizontal text; a sideways or upside-down scan silently returns garbage rather than an error. Detect orientation first with
pytesseract.image_to_osd(img)and rotate before running OCR. - Multi-column documents get jumbled. Tesseract reads left-to-right, top-to-bottom across the whole page, so two-column layouts interleave lines from both columns. Use
image_to_datawith bounding boxes and sort by column (x-position) before reassembling text. - Trusting low-confidence words.
image_to_datareturns a per-word confidence score; anything below ~50 is unreliable and should be flagged or dropped rather than trusted verbatim. - OCR-ing oversized images wastes time for no gain. Images over 5000px take significant time with no accuracy benefit past ~2000-3000px width — resize down first.
Verification Checklist
- Extracted text is non-empty and roughly matches the visible content when spot-checked against the source image
- Low-confidence words (below ~50 via
image_to_data) are flagged or excluded, not silently included - For rotated or scanned pages, orientation was checked/corrected before OCR, not assumed upright
- For multi-column layouts, column order in the output matches reading order, not raster scan order
- Language pack matches the actual document language (multi-language docs use
lang='eng+fra+...'as needed)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

