
Image Ocr
- 2 installs
- 595 repo stars
- Updated August 4, 2026
- aidotnet/opencowork
image-ocr is a Claude Code skill that extracts text from images using Tesseract OCR through Python.
About
image-ocr is a Claude Code skill that extracts text from images using Tesseract OCR through Python. A developer uses it to read text from screenshots, photos of documents, scanned pages or any image containing text. It runs ocr_extract.py with pytesseract and Pillow, supports multiple languages and offers preprocessing and page-segmentation options for better accuracy.
- Extracts text from images using Tesseract OCR via Python
- Supports multiple languages including English, Chinese and Japanese and image preprocessing
- Handles PNG, JPEG, TIFF, BMP and WebP with page-segmentation-mode control
Image Ocr by the numbers
- 2 all-time installs (skills.sh)
- Ranked #548 of 688 Office & Documents skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
image-ocr capabilities & compatibility
Free; needs Python, pytesseract, Pillow and the Tesseract engine.
- Capabilities
- ocr · text extraction · image processing
- Use cases
- transcription · pdf parsing
- Platforms
- macOS · Windows · Linux
- Pricing
- Free
What image-ocr says it does
Extract text from images using Tesseract OCR via Python.
Supports PNG, JPEG, TIFF, BMP, and WebP formats.
npx skills add https://github.com/aidotnet/opencowork --skill image-ocrAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2 |
|---|---|
| repo stars | ★ 595 |
| Last updated | August 4, 2026 |
| Repository | aidotnet/opencowork ↗ |
What it does
Extract text from screenshots, scanned documents and photos using Tesseract OCR with language and preprocessing options.
Who is it for?
Reading text out of screenshots, scanned pages and photos across multiple languages.
Skip if: Structured document editing or generating new documents.
When should I use this skill?
A user wants to read or extract text from an image, screenshot or scanned document.
What you get
Extracted text from images, printed to terminal or saved to a file.
- Extracted text output
- Saved text files from images
By the numbers
- 5 supported image formats (PNG, JPEG, TIFF, BMP, WebP)
- 4 preprocessing modes (none, grayscale, threshold, blur)
Files
Image OCR
Extract text from images using Tesseract OCR via Python.
When to use this skill
- User asks to read or extract text from an image
- User has a screenshot with text they want to process
- User has scanned documents that need text extraction
- User wants to digitize text from photos
Scripts overview
| Script | Purpose | Dependencies |
|---|---|---|
ocr_extract.py | Extract text from images with multiple options | pytesseract, Pillow |
Steps
1. Install dependencies (first time only)
Install the Python packages:
pip install pytesseract PillowInstall Tesseract OCR engine:
- Windows: Download installer from https://github.com/UB-Mannheim/tesseract/wiki
- macOS:
brew install tesseract - Linux (Ubuntu/Debian):
sudo apt install tesseract-ocr - Linux (Fedora):
sudo dnf install tesseract
For additional language support:
- Windows: Select languages during installation
- Linux:
sudo apt install tesseract-ocr-chi-sim(Chinese Simplified),tesseract-ocr-jpn(Japanese), etc.
CRITICAL — Dependency Error Recovery: If the script fails with an ImportError or "tesseract not found" error, install the missing dependencies using the commands above, then re-run the EXACT SAME script command that failed.2. Extract text from an image
python scripts/ocr_extract.py "IMAGE_PATH"Options:
--lang LANG— OCR language (default:eng). Usechi_simfor Chinese,jpnfor Japanese,eng+chi_simfor multiple.--save OUTPUT_PATH— Save extracted text to a file--preprocess MODE— Image preprocessing:none(default),grayscale,threshold,blur--dpi DPI— Set image DPI for better accuracy (default: auto-detect)--psm MODE— Tesseract page segmentation mode (0-13, default: 3 = auto)
Examples:
# Basic text extraction
python scripts/ocr_extract.py "screenshot.png"
# Chinese text extraction
python scripts/ocr_extract.py "document.jpg" --lang chi_sim
# Mixed English and Chinese
python scripts/ocr_extract.py "mixed.png" --lang eng+chi_sim
# Preprocess noisy image for better accuracy
python scripts/ocr_extract.py "noisy_scan.png" --preprocess threshold
# Save output to file
python scripts/ocr_extract.py "scan.tiff" --save output.txt
# Single line of text (e.g., license plate, serial number)
python scripts/ocr_extract.py "plate.jpg" --psm 7Page Segmentation Modes (PSM)
| Mode | Description | Use Case |
|---|---|---|
| 3 | Fully automatic (default) | General documents |
| 4 | Assume single column | Single-column text |
| 6 | Assume single block | Uniform text block |
| 7 | Single line | One line of text |
| 8 | Single word | One word |
| 11 | Sparse text | Text scattered on image |
| 13 | Raw line | Single line, no OSD |
Edge cases
- Low quality images: Use
--preprocess thresholdor--preprocess blurto improve results - Rotated text: Tesseract handles slight rotation; for heavily rotated images, rotate first
- Very small text: Increase DPI with
--dpi 300or higher - Mixed languages: Combine with
+, e.g.,--lang eng+chi_sim+jpn - Empty results: Try different PSM modes or preprocessing options
Scripts
- ocr_extract.py — Extract text from images using Tesseract OCR
#!/usr/bin/env python3
"""
Extract text from images using Tesseract OCR.
Dependencies: pytesseract, Pillow
System requirement: Tesseract OCR engine installed
"""
import argparse
import sys
import os
try:
import pytesseract
from PIL import Image, ImageFilter
except ImportError as e:
print(f"Missing dependency: {e}", file=sys.stderr)
print("Install with: pip install pytesseract Pillow", file=sys.stderr)
print("Also install Tesseract OCR engine on your system.", file=sys.stderr)
sys.exit(1)
def preprocess_image(img, mode):
"""Apply preprocessing to improve OCR accuracy."""
if mode == 'grayscale':
return img.convert('L')
elif mode == 'threshold':
gray = img.convert('L')
return gray.point(lambda x: 0 if x < 128 else 255, '1')
elif mode == 'blur':
return img.filter(ImageFilter.MedianFilter(size=3))
return img
def extract_text(image_path, lang='eng', preprocess='none', dpi=None, psm=3):
"""Extract text from an image file."""
if not os.path.isfile(image_path):
print(f"Error: File not found: {image_path}", file=sys.stderr)
sys.exit(1)
try:
img = Image.open(image_path)
except Exception as e:
print(f"Error opening image: {e}", file=sys.stderr)
sys.exit(1)
# Apply preprocessing
if preprocess != 'none':
img = preprocess_image(img, preprocess)
# Build Tesseract config
config_parts = [f'--psm {psm}']
if dpi:
config_parts.append(f'--dpi {dpi}')
config = ' '.join(config_parts)
try:
text = pytesseract.image_to_string(img, lang=lang, config=config)
except pytesseract.TesseractNotFoundError:
print("Error: Tesseract OCR engine not found.", file=sys.stderr)
print("Install it:", file=sys.stderr)
print(" Windows: https://github.com/UB-Mannheim/tesseract/wiki", file=sys.stderr)
print(" macOS: brew install tesseract", file=sys.stderr)
print(" Linux: sudo apt install tesseract-ocr", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"OCR error: {e}", file=sys.stderr)
sys.exit(1)
return text.strip()
def main():
parser = argparse.ArgumentParser(
description='Extract text from images using Tesseract OCR'
)
parser.add_argument('image', help='Path to the image file')
parser.add_argument(
'--lang', default='eng',
help='OCR language (default: eng). Examples: chi_sim, jpn, eng+chi_sim'
)
parser.add_argument(
'--save', metavar='OUTPUT',
help='Save extracted text to a file'
)
parser.add_argument(
'--preprocess', default='none',
choices=['none', 'grayscale', 'threshold', 'blur'],
help='Image preprocessing mode (default: none)'
)
parser.add_argument(
'--dpi', type=int, default=None,
help='Set image DPI for better accuracy'
)
parser.add_argument(
'--psm', type=int, default=3,
help='Tesseract page segmentation mode 0-13 (default: 3 = auto)'
)
args = parser.parse_args()
text = extract_text(
args.image,
lang=args.lang,
preprocess=args.preprocess,
dpi=args.dpi,
psm=args.psm
)
if not text:
print("(No text detected in image)", file=sys.stderr)
print("Tips: try --preprocess threshold, different --psm mode, or --lang option",
file=sys.stderr)
else:
print(text)
if args.save:
with open(args.save, 'w', encoding='utf-8') as f:
f.write(text)
print(f"\nText saved to {args.save}", file=sys.stderr)
if __name__ == '__main__':
main()
Related skills
FAQ
What does image-ocr require to run?
Python 3 with pytesseract and Pillow, plus the Tesseract OCR engine installed on the system.
Which image formats are supported?
PNG, JPEG, TIFF, BMP and WebP formats are supported.