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
小蔥技能7w4.net有更新,你可以訪問看下。
scripts/ocr.py - Main OCR script
chi_sim language pack--psm flag for specific page segmentation modes這是一款實用的影像文字識別工具,中文識別效果好,支援多平臺使用。安裝和配置說明詳細,錯誤提示友好。但文件與實際指令碼名稱存在不一致,版本資訊也有出入。對於普通使用者而言功能是可靠的,但使用前需注意閱讀最新文件確認正確的指令碼名稱。