CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

OCRmyPDF

$ ocrmypdf 官方出品 低风险
OCRmyPDF · AI 能力与音视频 · MPL-2.0 · macos / linux / windows

OCRmyPDF(ocrmypdf)结合 Tesseract 与 Ghostscript/qpdf 为扫描版 PDF 添加不可见的可搜索文本层,同时保持原图像画质并支持生成 PDF/A 归档格式。提供确定性退出码、--deskew 自动纠偏、--sidecar 纯文本提取以及适合脚本化管道的 -q/--quiet 静默参数。

FCRS-1.0 综合评分
82 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install ocrmypdf
CLI vs MCP 选型建议 仅 CLI 可用

ocrmypdf 直接在本地对磁盘上的多页 PDF 编排 Tesseract、Ghostscript 与 qpdf 二进制程序,无需任何 MCP 封装。

Agent 友好度体检单

— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 18 / 25

完全非交互运行,支持 --quiet、--sidecar 文本提取与明确的数值退出码,但缺少 --json 输出。

  • --quiet, --sidecar, and --output-type none support clean scripting
  • No --json output formatting
安全与权限边界 22 / 25

100% 本地离线处理且无任何网络访问,输入输出文件路径显式分离,并支持 --skip-text 防止误改数字文本页。

  • Zero network calls; explicit input.pdf output.pdf separation
  • Deterministic exit codes for CI error handling
安装与运行摩擦 13 / 15

在 macOS/Linux 可通过 brew install ocrmypdf 一键连带安装 Tesseract、Ghostscript 与 qpdf,也支持 PyPI 与各 Linux 发行版包管理器。

  • One-command brew install ocrmypdf includes native Tesseract/Ghostscript deps
能力覆盖与边际价值 12 / 15

可搜索 PDF/A 生成的行业标杆,支持多核并发(--jobs)、自动纠偏与附属纯文本提取。

  • Handles --deskew, --rotate-pages, --sidecar, and PDF/A output
维护与来源背书 9 / 10

长期稳健维护的官方仓库(ocrmypdf/OCRmyPDF),采用 MPL-2.0 协议。

  • Official ocrmypdf/OCRmyPDF repo under MPL-2.0
文档与可验证性 8 / 10

ReadTheDocs 手册详尽,包含实用 Cookbook 配方与完整退出码说明。

  • Comprehensive ReadTheDocs manual and exit-code docs

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

100% 本地离线运行,无需任何凭据或 API 密钥。

潜在副作用
只读查询 本地写入
费用与配额提示

MPL-2.0 开源 CLI,本地使用完全免费(注意其底层依赖 Ghostscript 采用 AGPLv3 协议)。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# OCRmyPDF CLI (ocrmypdf) Agent Rules
- Always write to a new output path (`ocrmypdf in.pdf out.pdf`) rather than overwriting `in.pdf` in place.
- Combine `--deskew` with `--skip-text` so PDFs that already contain text layers do not fail.
- Pass `-q` / `--quiet` in automated scripts to suppress progress bars.

Agent 高频安全命令配方

只读查询(安全推荐)

提取 OCR 文本至附属文本文件而不生成 PDF
ocrmypdf --output-type none --sidecar extracted.txt --quiet scanned.pdf -

执行 OCR 并仅将提取的纯文本写入 extracted.txt,不生成输出 PDF 文件。

受控写入与预演

纠偏并为扫描 PDF 添加可搜索文本层
ocrmypdf --deskew --skip-text --quiet scanned.pdf searchable.pdf

自动拉直倾斜扫描页、通过 --skip-text 跳过已有文本页并输出 searchable.pdf。

核心优势

  • + brew install ocrmypdf 可一站式搞定 Tesseract 与 Ghostscript 原生依赖。
  • + 确定性退出码、--skip-text 与 --sidecar 让批量 PDF 处理流水线非常可靠。

注意事项与踩坑点

  • ! 输出为 PDF 与纯文本 --sidecar 文件,不支持 --json 输出。
  • ! 对已含文本层的 PDF 使用 --deskew 时,必须同时传入 --skip-text 或 --force-ocr,否则会报错退出。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI