name: image-ocr description: "Extract text from images using Tesseract OCR (supports Chinese, English, and other languages)." version: 1.1.0 author: Hermes Agent license: MIT platforms: [windows, macos, linux] metadata: hermes: tags: [OCR, Image, Text-Extraction, Chinese, English, Cross-Platform]
Extract text from images using Tesseract OCR engine with Python wrapper. Cross-platform support for Windows, macOS, and Linux.
pytesseract, Pillowchi_sim) and English (eng) recommended| Platform | Command |
|---|---|
| Windows | Download from UB-Mannheim/tesseract |
| macOS | brew install tesseract |
| Linux | sudo apt install tesseract-ocr (Debian/Ubuntu) |
pip install pytesseract Pillow
python scripts/ocr.py <image_path> [-l LANGUAGE] [--psm PSM]
Examples:
# Auto-detect Tesseract, use default language (chi_sim+eng)
python scripts/ocr.py screenshot.png
# Specify language
python scripts/ocr.py document.jpg -l chi_sim+eng
# Specify page segmentation mode
python scripts/ocr.py photo.jpg -l eng --psm 6
# Specify Tesseract path manually
python scripts/ocr.py image.png --tesseract-path "C:\Program Files\Tesseract-OCR"
# List installed language packs
python scripts/ocr.py --list-langs
The script finds Tesseract automatically in this order:
--tesseract-path CLI argumentTESSERACT_PATH environment variable~/.config/image-ocr/config.json or %APPDATA%/image-ocr/config.json)C:\Program Files\Tesseract-OCR, C:\Program Files (x86)\Tesseract-OCR/usr/local/bin/tesseract, /opt/homebrew/bin/tesseract/usr/bin/tesseract, /usr/local/bin/tesseractPATHCreate a JSON config file to set a persistent Tesseract path:
Windows: %APPDATA%\image-ocr\config.json
macOS/Linux: ~/.config/image-ocr/config.json
{
"tesseract_path": "/path/to/tesseract"
}
| Language | Code | Description |
|---|---|---|
| Chinese Simplified | chi_sim |
简体中文 |
| Chinese Traditional | chi_tra |
繁體中文 |
| English | eng |
English |
| Japanese | jpn |
日本語 |
| Korean | kor |
한국어 |
Combine multiple languages: chi_sim+eng
scripts/ocr.py - Main OCR script小葱技能7w4.net有完整的技能分类。
chi_sim language pack--psm flag for specific page segmentation modes这是一款实用的图像文字识别工具,中文识别效果好,支持多平台使用。安装和配置说明详细,错误提示友好。但文档与实际脚本名称存在不一致,版本信息也有出入。对于普通用户而言功能是可靠的,但使用前需注意阅读最新文档确认正确的脚本名称。