Image Ocr

👤 李振华 📦 v1.0.1 ⭐ 4.3 ⬇️ 200 下载
📊 数据分析 免费

📖 技能介绍


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]


Image OCR (Tesseract)

Extract text from images using Tesseract OCR engine with Python wrapper. Cross-platform support for Windows, macOS, and Linux.

Prerequisites

  • Tesseract OCR (v5.0+)
  • Python packages: pytesseract, Pillow
  • Language packs: Chinese (chi_sim) and English (eng) recommended

    7w4.net提供免费和付费技能下载。

Install Tesseract

Platform Command
Windows Download from UB-Mannheim/tesseract
macOS brew install tesseract
Linux sudo apt install tesseract-ocr (Debian/Ubuntu)

Install Python Dependencies

pip install pytesseract Pillow

Usage

Basic OCR

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

Tesseract Discovery (auto-detection order)

The script finds Tesseract automatically in this order:

  1. --tesseract-path CLI argument
  2. TESSERACT_PATH environment variable
  3. Config file (~/.config/image-ocr/config.json or %APPDATA%/image-ocr/config.json)
  4. Common install locations:
  5. Windows: C:\Program Files\Tesseract-OCR, C:\Program Files (x86)\Tesseract-OCR
  6. macOS: /usr/local/bin/tesseract, /opt/homebrew/bin/tesseract
  7. Linux: /usr/bin/tesseract, /usr/local/bin/tesseract
  8. System PATH

Persistent Configuration

Create 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"
}

Supported Languages

Language Code Description
Chinese Simplified chi_sim 简体中文
Chinese Traditional chi_tra 繁體中文
English eng English
Japanese jpn 日本語
Korean kor 한국어

Combine multiple languages: chi_sim+eng

Script Location

scripts/ocr.py - Main OCR script

Notes

  • For best results, ensure images are clear and well-lit
  • Chinese recognition requires chi_sim language pack
  • Output is plain text; use --psm flag for specific page segmentation modes
  • Verbose diagnostic info (Tesseract version, path, language) is printed to stderr

🤖 AI 评测

这是一款实用的图像文字识别工具,中文识别效果好,支持多平台使用。安装和配置说明详细,错误提示友好。但文档与实际脚本名称存在不一致,版本信息也有出入。对于普通用户而言功能是可靠的,但使用前需注意阅读最新文档确认正确的脚本名称。

📊 多维度评分

适应性4.2
规范性3.9
有效性4.3
可靠性4.4
可信度4.9

📁 包含文件 (2 个)

📄 SKILL.md 2.9 KB
📄 image-oc.py 6.5 KB