PDF和图片文字提取

v1.0.0

从图片或 PDF 文档中识别并提取文字内容,支持多种图片格式和 PDF 文件,自动判断是否包含文字并保留原始格式输出结构化结果;当用户需要从图片或 PDF 提取文字、进行 OCR 识别、处理含文字的文档或转换为可编辑文本时使用

0· 96·0 current·0 all-time
byto the moon@yuanyi-github

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for yuanyi-github/image-text-extractor.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "PDF和图片文字提取" (yuanyi-github/image-text-extractor) from ClawHub.
Skill page: https://clawhub.ai/yuanyi-github/image-text-extractor
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install image-text-extractor

ClawHub CLI

Package manager switcher

npx clawhub@latest install image-text-extractor
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
The skill claims to handle both images and PDFs. The included script (scripts/pdf_text_extractor.py) only processes text-based PDF content via PyMuPDF; image OCR is delegated in SKILL.md to a platform 'read_image' tool. SKILL.md also sometimes implies support for scanned PDFs but the script itself does not perform OCR — it will return empty text for image-only pages and advise using OCR. This is a minor mismatch but explainable (PDF handling vs OCR delegation).
Instruction Scope
Runtime instructions are narrow: obtain image URL or local PDF path, call the platform 'read_image' tool for images, and run the bundled Python script for PDFs. The script reads only the provided file path, validates suffix, extracts text with PyMuPDF, returns JSON, and does not access other files, environment variables, or external endpoints.
Install Mechanism
No automated install spec is included (instruction-only). SKILL.md documents a single dependency (pymupdf) and suggests 'pip install pymupdf>=1.23.0'. There are no downloads from arbitrary URLs or archive extraction steps in the package.
Credentials
The skill requests no environment variables, credentials, or config paths. The code does not reference any secrets or external services. This is proportionate to the stated function.
Persistence & Privilege
The skill is not always-enabled, is user-invocable, and does not modify other skills or system settings. The script does not write persistent state; SKILL.md states files are only used in-session.
Assessment
This skill appears to do what it says for text-based PDFs and is not requesting credentials or making external network calls. Before installing, confirm two things: (1) your agent/platform supplies a 'read_image' tool (SKILL.md relies on it for image OCR) or you have a separate OCR tool — the bundled script does not perform OCR on scanned/image pages; (2) you are comfortable installing the PyMuPDF (pymupdf) Python package. Also note the package source/homepage is unknown — if provenance matters to you, request the author's origin or review the code yourself (the included script is short and local). If you need automatic OCR of scanned PDFs or images, verify the agent has an OCR tool or extend the skill to include one.

Like a lobster shell, security has layers — review code before you run it.

latestvk977gtnd3r7w248y727sbpqqjh84vwjs
96downloads
0stars
1versions
Updated 2w ago
v1.0.0
MIT-0

文档文字提取器

任务目标

  • 本 Skill 用于:从用户上传的图片或 PDF 文档中识别并提取文字内容
  • 能力包含:图片文字检测、PDF 文字提取、格式保留、结构化输出、Markdown 文件生成
  • 触发条件:用户上传图片或 PDF 并要求提取文字,或询问文档中的文字内容

前置准备

依赖说明

脚本所需的依赖包及版本:

pymupdf>=1.23.0

安装命令:

pip install pymupdf>=1.23.0

支持的文件格式

  • 图片格式:PNG、JPG、JPEG、GIF、WebP、BMP 等常见格式
  • 文档格式:PDF(支持扫描版和文字版)

操作步骤

标准流程

图片文字提取流程

  1. 接收图片

    • 确认用户已上传图片文件
    • 获取图片的访问 URL
  2. 识别图片内容

    • 使用 read_image 工具识别图片内容
    • 在 prompt 中明确要求识别所有文字内容,包括标题、正文、注释、水印等
  3. 判断文字存在性

    • 如果检测到文字:进入步骤 4
    • 如果未检测到文字:告知用户"图片中未包含可提取的文字",任务结束
  4. 提取并整理文字

    • 提取图片中的所有文字内容
    • 保持原有的结构和排版
    • 整理为易读的格式

PDF 文字提取流程

  1. 接收 PDF 文件

    • 确认用户已上传 PDF 文件
    • 获取 PDF 文件的本地路径
  2. 调用脚本提取文字

    • 执行命令:python scripts/pdf_text_extractor.py <pdf_file_path>
    • 脚本会自动提取所有页面的文本
    • 尽量保留原文的段落结构和标题层级
  3. 处理提取结果

    • 如果提取成功:进入步骤 4
    • 如果提取失败:告知用户错误信息,任务结束
  4. 格式化输出

    • 脚本返回的文本为 Markdown 格式
    • 可直接展示或保存为文件

统一输出步骤

  1. 生成输出结果
    • 根据用户需求生成 Markdown 文件
    • 包含文件来源、提取状态、文字内容等信息
    • 使用清晰的标题和结构组织内容

可选分支

  • 当用户仅需查看文字内容:直接输出文字,不生成文件
  • 当用户要求保存结果:生成 .md 文件
  • 当图片/PDF 文字模糊或难以识别:说明情况并提供最佳识别结果
  • 当 PDF 包含扫描图片:提示用户该页面为扫描图片,可能需要 OCR 处理

资源索引

  • 必要脚本:见 scripts/pdf_text_extractor.py
    • 用途:从 PDF 文件中提取文本内容并保留格式
    • 参数:PDF 文件路径
    • 输出:JSON 格式结果,包含提取的文本和元信息

注意事项

图片文字提取

  • 识别准确性:文字识别结果受图片清晰度、字体、背景等因素影响,可能存在误差
  • 文字排版:提取时尽量保持原图的文字结构和顺序
  • 多语言支持:支持识别中文、英文等多种语言文字

PDF 文字提取

  • 格式保留:脚本会尽量保留原文的段落结构和标题层级
  • 扫描版 PDF:如果 PDF 是扫描图片,文字可能无法提取,需要告知用户
  • 复杂布局:表格、多栏等复杂布局的提取效果可能不佳
  • 加密 PDF:不支持加密或受密码保护的 PDF 文件

通用注意事项

  • 隐私保护:处理的文件不会被存储,仅在当前会话中使用
  • 文件大小:建议处理小于 50MB 的文件,过大文件可能导致处理缓慢

使用示例

示例 1:图片文字提取

用户操作:上传一张包含文字的图片

智能体处理

  1. 使用 read_image 工具识别图片
  2. 提取文字内容:"所有经历的纠缠 / 还有难过的遗憾 / 都不可能没有意义"
  3. 直接输出提取结果

示例 2:PDF 文字提取并保存

用户操作:上传 PDF 并要求"提取这个 PDF 的文字"

智能体处理

  1. 确认 PDF 文件路径
  2. 执行脚本:python scripts/pdf_text_extractor.py ./document.pdf
  3. 获取提取结果,包含 10 页内容
  4. 生成 Markdown 文件:./extracted_from_pdf.md

示例 3:处理扫描版 PDF

用户操作:上传扫描版 PDF

智能体处理

  1. 执行脚本提取文字
  2. 发现部分页面提取为空
  3. 告知用户:"检测到部分页面可能为扫描图片,文字无法直接提取。建议使用 OCR 工具处理。"

Comments

Loading comments...