返回顶部
i

image-reader图片识别

识别本地图片内容(支持中文),通过 OCR.space 免费 API 实现。

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
150
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

image-reader

image-reader 技能

识别本地图片内容(支持中文),通过 OCR.space 免费 API 实现。

工作流程

  1. 1. 接收图片路径
  2. 调用 OCR.space API 进行识别
  3. 返回识别结果

Python 脚本

保存到 {skillroot}/scripts/ocrimage.py:

python
import urllib.request, urllib.parse, base64, io, json, sys
from PIL import Image

img_path = sys.argv[1] if len(sys.argv) > 1 else sys.stdin.read().strip()

img = Image.open(img_path)
img_small = img.resize((1600, 2400), Image.LANCZOS)
buf = io.BytesIO()
img_small.save(buf, format=JPEG, quality=80)
b64_data = base64.b64encode(buf.getvalue()).decode()

url = https://api.ocr.space/parse/image
params = urllib.parse.urlencode({
base64Image: data:image/jpeg;base64, + b64_data,
language: chs,
isOverlayRequired: false,
detectOrientation: true,
scale: true,
OCREngine: 2,
})
data = params.encode(utf-8)

req = urllib.request.Request(url, data=data)
req.add_header(Content-Type, application/x-www-form-urlencoded)
req.add_header(apikey, helloworld) # OCR.space 免费演示密钥

with urllib.request.urlopen(req, timeout=30) as resp:
raw = resp.read()
result = json.loads(raw.decode(utf-8, errors=replace))
if ParsedResults in result:
for r in result[ParsedResults]:
print(r[ParsedText])
else:
print(OCR识别失败:, result)

使用方式

bash
python {skillroot}/scripts/ocrimage.py F:/1.jpg

依赖

  • - Python 3
  • Pillow (pip install pillow)

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 image-reader-xytest-1776019741 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 image-reader-xytest-1776019741 技能

通过命令行安装

skillhub install image-reader-xytest-1776019741

下载

⬇ 下载 image-reader v1.0.0(免费)

文件大小: 2.6 KB | 发布时间: 2026-4-13 10:38

v1.0.0 最新 2026-4-13 10:38
- Initial release of image-reader skill.
- Recognizes content from local images (including Chinese) using the free OCR.space API.
- Includes a Python script for submitting images and returning extracted text.
- Easy CLI usage; requires Python 3 and Pillow.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部