Skill: 15914355527/ocr-local-v2 (version 1.0.0)

--- name: ocr-local description: Extract text from images using Tesseract.js OCR (100% local, no API key required). Supports Chinese (simplified/traditional) and English. homepage: https://github.com/naptha/tesseract.js metadata: {"openclaw":{"emoji":"📝","requires":{"bins":["node"]},"install":[{"id":"npm","kind":"npm","packages":["tesseract.js"],"label":"Install tesseract.js"}]}} --- # OCR - Image Text Recognition (Local) Extract text from images using Tesseract.js. **100% local run, no API key required.** Supports Chinese and English. ## Quick start ```bash node {baseDir}/scripts/ocr.js /path/to/image.jpg node {baseDir}/scripts/ocr.js /path/to/image.png --lang chi_sim node {baseDir}/scripts/ocr.js /path/to/image.jpg --lang chi_tra+eng ``` ## Options - `--lang <langs>`: Language codes (default: chi_sim+eng) - `chi_sim` - Simplified Chinese - `chi_tra` - Traditional Chinese - `eng` - English - Combine with `+`: `chi_sim+eng` - `--json`: Output as JSON instead of plain text ## Examples ```bash # Recognize Chinese screenshot node {baseDir}/scripts/ocr.js screenshot.png # Recognize English document node {baseDir}/scripts/ocr.js document.jpg --lang eng # Mixed Chinese + English node {baseDir}/scripts/ocr.js mixed.png --lang chi_sim+eng ``` ## Notes - First run downloads language data (~20MB per language) - Subsequent runs are cached locally - Works best with clear, high-contrast images - For handwritten text, accuracy may vary

path: PUBLISH.md
content: # OCR Skill 发布清单

## 文件结构

```
ocr/
├── SKILL.md           # OpenClaw 技能定义（必需）
├── package.json       # NPM 配置和依赖
├── README.md          # 使用说明
├── .gitignore         # Git 忽略文件
├── scripts/
│   └── ocr.js         # OCR 主脚本
└── PUBLISH.md         # 本文件
```

## 发布步骤

### 1. 确认文件完整
- [x] SKILL.md - 技能定义
- [x] package.json - NPM 配置
- [x] README.md - 使用文档
- [x] scripts/ocr.js - 主脚本
- [x] .gitignore - Git 配置

### 2. 清理不必要文件
已删除：
- ❌ node_modules/ - 用户安装时会自动下载
- ❌ *.traineddata - Tesseract 语言数据（运行时自动下载）
- ❌ package-lock.json - 让用户使用最新版本

### 3. 发布到 ClawHub

**方式 A：使用 CLI**
```bash
cd ~/.openclaw/workspace/skills/ocr
clawhub publish . --changelog "Initial release - OCR skill with Tesseract.js support for Chinese and English text recognition"
```

**方式 B：通过网站**
1. 访问 https://clawhub.com
2. 登录账号
3. 点击 "Publish Skill"
4. 上传整个 `ocr` 文件夹

### 4. 发布后验证

```bash
# 搜索技能
clawhub search ocr

# 安装测试
clawhub install ocr

# 测试使用
node ~/.openclaw/workspace/skills/ocr/scripts/ocr.js test-image.jpg
```

## 技能信息

- **名称**: OCR - Image Text Recognition
- **版本**: 1.0.0
- **作者**: OpenClaw Community
- **许可**: MIT
- **分类**: Productivity
- **标签**: ocr, image, text-recognition, tesseract, chinese, image-to-text

## 功能特性

✅ 支持简体中文识别
✅ 支持繁体中文识别
✅ 支持英文识别
✅ 多语言混合识别
✅ 纯本地运行（无需 API Key）
✅ 支持 JSON 格式输出

## 依赖

- Node.js >= 18.0.0
- tesseract.js ^7.0.0

## 首次运行说明

用户首次使用时会下载 Tesseract 语言数据（约 20MB/语言），后续运行使用缓存。

---

**准备就绪，可以发布！** 🚀


path: README.md
content: # OCR Skill for OpenClaw

📝 Extract text from images using Tesseract.js OCR.

## Features

- **Multi-language support**: Simplified Chinese, Traditional Chinese, English
- **Easy to use**: Single command to recognize any image
- **Flexible output**: Plain text or JSON format
- **No API key required**: Runs locally with Tesseract.js

## Installation

```bash
# Via ClawHub (recommended)
# Coming soon to ClawHub

# Manual installation
git clone https://github.com/openclaw/skill-ocr.git ~/.openclaw/workspace/skills/ocr
cd ~/.openclaw/workspace/skills/ocr
npm install
```

## Usage

```bash
# Basic usage (Chinese + English)
node {baseDir}/scripts/ocr.js /path/to/image.jpg

# Specify language
node {baseDir}/scripts/ocr.js image.png --lang chi_sim
node {baseDir}/scripts/ocr.js image.png --lang chi_tra+eng
node {baseDir}/scripts/ocr.js image.png --lang eng

# JSON output
node {baseDir}/scripts/ocr.js image.jpg --json
```

## Language Codes

- `chi_sim` - Simplified Chinese
- `chi_tra` - Traditional Chinese
- `eng` - English
- Combine with `+`: `chi_sim+eng`, `chi_tra+eng`

## Examples

### Recognize a screenshot
```bash
node ~/.openclaw/workspace/skills/ocr/scripts/ocr.js ~/Downloads/screenshot.png
```

### Extract text from a photo of document
```bash
node ~/.openclaw/workspace/skills/ocr/scripts/ocr.js document.jpg --lang chi_sim+eng
```

### Get structured output with confidence scores
```bash
node ~/.openclaw/workspace/skills/ocr/scripts/ocr.js image.jpg --json
```

## Notes

- First run downloads Tesseract.js language data (~20MB per language)
- Subsequent runs use cached data
- Works best with clear, high-contrast images
- Handwritten text recognition accuracy may vary
- For best results, ensure images are well-lit and text is clearly visible

## License

MIT License

## Credits

Powered by [Tesseract.js](https://github.com/naptha/tesseract.js)


path: _meta.json
content: ownerId: kn76tv0e2bf2bjea89hadd010n82xz04
slug: ocr-local
version: 1.0.0
publishedAt: 1773531509815

path: package.json
content: {
  "name": "ocr",
  "version": "1.0.0",
  "description": "OCR skill for extracting text from images using Tesseract.js. Supports Chinese (simplified/traditional) and English.",
  "main": "scripts/ocr.js",
  "scripts": {
    "test": "node scripts/ocr.js --help"
  },
  "keywords": ["ocr", "image", "text-recognition", "tesseract", "chinese", "image-to-text"],
  "author": "OpenClaw Community",
  "license": "MIT",
  "acceptLicenseTerms": true,
  "dependencies": {
    "tesseract.js": "^7.0.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/openclaw/skill-ocr.git"
  },
  "private": true
}


path: scripts/ocr.js
content: #!/usr/bin/env node

/**
 * OCR - Image Text Recognition using Tesseract.js
 * Usage: node ocr.js <image> [--lang chi_sim+eng] [--json]
 */

const Tesseract = require('tesseract.js');
const path = require('path');
const fs = require('fs');

// Parse arguments
const args = process.argv.slice(2);
const imagePath = args.find(a => !a.startsWith('--'));
const langArg = args.find(a => a === '--lang');
const langIndex = langArg ? args.indexOf(langArg) : -1;
const languages = langIndex >= 0 && args[langIndex + 1] ? args[langIndex + 1] : 'chi_sim+eng';
const outputJson = args.includes('--json');

if (!imagePath) {
  console.error('Usage: node ocr.js <image> [--lang chi_sim+eng] [--json]');
  console.error('');
  console.error('Options:');
  console.error('  --lang <langs>  Language codes (default: chi_sim+eng)');
  console.error('                  chi_sim = Simplified Chinese');
  console.error('                  chi_tra = Traditional Chinese');
  console.error('                  eng = English');
  console.error('  --json          Output as JSON');
  process.exit(1);
}

// Resolve image path
const resolvedPath = path.isAbsolute(imagePath) 
  ? imagePath 
  : path.join(process.cwd(), imagePath);

if (!fs.existsSync(resolvedPath)) {
  console.error(`Error: Image not found: ${resolvedPath}`);
  process.exit(1);
}

async function recognize() {
  try {
    console.error(`📝 Recognizing text from: ${path.basename(imagePath)}`);
    console.error(`🌐 Languages: ${languages}`);
    console.error('');

    const result = await Tesseract.recognize(
      resolvedPath,
      languages,
      {
        logger: m => {
          if (m.status === 'recognizing text') {
            process.stderr.write(`\r⏳ Progress: ${Math.round(m.progress * 100)}%`);
          }
        }
      }
    );

    console.error('\n');
    
    if (outputJson) {
      console.log(JSON.stringify({
        text: result.data.text,
        confidence: result.data.confidence,
        words: result.data.words.map(w => ({
          text: w.text,
          confidence: w.confidence,
          bbox: w.bbox
        }))
      }, null, 2));
    } else {
      console.log(result.data.text);
    }

  } catch (error) {
    console.error(`❌ Error: ${error.message}`);
    process.exit(1);
  }
}

recognize();


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)