/paperfit:visual-inspectorfrom paperfit
Renders LaTeX PDF pages to high-resolution images for visual layout inspection. Part of the PaperFit pipeline, invoked after compilation to generate page images for review.
Ships in paperfit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
本技能是 PaperFit 视觉排版优化闭环中的关键环节,专门负责 PDF 页图渲染与视觉验收指导。它封装了将 PDF 转换为逐页高分辨率图片的标准化流程,并为 layout-detective-agent 和 quality-gatekeeper-agent 提供详细的逐页视觉检查清单。
该技能由 orchestrator-agent 在每次编译后调用,确保多模态证据链中的“页图”环节可靠、一致且可复现。
/check-visual 命令)。| 输入项 | 来源 | 必需 | 说明 |
|---|---|---|---|
| PDF 文件路径 | 编译输出 | ✅ | 通常为 main.pdf |
| 输出目录 | 配置或默认 | ✅ | 页图存放目录,默认为 data/pages/ |
| DPI 参数 | 配置或调用方指定 | ✅ | 渲染分辨率,默认 220 DPI |
| 页码范围 | 调用方指定 | ⚠️ | 若为空,渲染全部页面 |
| 局部裁剪参数 | 调用方指定 | ⚠️ | 如 {page: 5, bbox: [x,y,w,h]},用于表格/公式局部复查 |
| PDF native geometry | 编译输出 PDF | ⚠️ | 若安装 PyMuPDF,可作为 B2 宽度和 D1 overflow 的辅助机器信号 |
本技能输出两份产物:
page_001.png、page_002.png 等。{
"skill": "visual-inspector",
"status": "success | partial | failed",
"pdf_path": "main.pdf",
"output_dir": "data/pages/",
"dpi": 220,
"pages_rendered": 9,
"page_files": [
{"page": 1, "file": "data/pages/page_001.png", "width": 1700, "height": 2200},
{"page": 2, "file": "data/pages/page_002.png", "width": 1700, "height": 2200}
],
"cropped_regions": [
{
"page": 5,
"object": "Table 2",
"file": "data/pages/page_005_table2.png",
"bbox": [100, 450, 800, 300]
}
],
"errors": []
}
pdf2image 库pdftoppm 或 pdftocairo)若 Poppler 未安装,根据操作系统提供安装指引:
# Debian/Ubuntu
sudo apt-get install poppler-utils
# macOS
brew install poppler
# Windows
# 下载 poppler 并添加到 PATH,或使用 conda install -c conda-forge poppler
可选 native geometry 检测依赖:
PyMuPDF(Python import 名为 fitz):用于读取 PDF 原生 object/text bbox,辅助检测 B2 宽度不足/超宽与 D1 native overflow。禁止在用户 LaTeX 项目里假设存在 scripts/render_pages.py。页图渲染由 PaperFit npm/CLI 包提供,在论文项目根目录执行:
paperfit render <相对或绝对路径的.pdf> --output data/pages --dpi 220
# 示例
paperfit render main.pdf --dpi 300
前提:npm install -g paperfit-cli(或等价全局安装),paperfit 在 PATH 中。输出目录 --output 相对于当前工作目录(一般为论文根目录)。
其它包内 Python/Bash(如 parse_log.py、state_manager.py)一律在论文根目录使用 paperfit run scripts/<文件名> [参数…],勿在用户项目里假设存在同名 scripts/。
若仅能通过 Python 调用包内脚本,先执行 paperfit root 得到包根目录,再:
python3 "$(paperfit root)/scripts/render_pages.py" main.pdf --dpi 220
(或直接调用 pdf2image 库,逻辑须与下方一致。)全局未装 paperfit 时可用:npx paperfit-cli render …。
from pdf2image import convert_from_path
pages = convert_from_path(
pdf_path,
dpi=220,
fmt='png',
thread_count=2,
grayscale=False,
size=None
)
for i, page in enumerate(pages, start=1):
page.save(f"{output_dir}/page_{i:03d}.png", "PNG")
| 场景 | DPI | 说明 |
|---|---|---|
| 整页常规检查 | 180-220 | 平衡清晰度与文件大小 |
| 表格/公式细节复查 | 260-320 | 需清晰辨认小字号或密集内容 |
| 局部裁剪复查 | 320 | 聚焦特定区域,可接受较大文件 |
当 runtime 已记录编译 PDF 路径时,视觉聚合阶段可调用:
paperfit run scripts/visual_signal_aggregator.py data/pages --output data/visual_signal_report.json --pdf main.pdf
该报告会把 native PDF bbox 映射到渲染页图坐标,并输出:
source=pymupdf_nativesubtype=underfilled_width 或 subtype=overflow_widthwidth_context、object_width_ratio、object_width_page_ratiooverflow_pt 与 pdf_bbox使用这些信号时必须回看对应 page_*.png;不要只凭 PDF 文本/对象抽取宣称视觉修复成功。
当 layout-detective-agent 需要对特定表格、公式或段落进行高精度复查时,可请求渲染局部区域。
page_005_table2.png)。裁剪示例:
from PIL import Image
full_page = Image.open(f"{output_dir}/page_005.png")
cropped = full_page.crop((x1, y1, x2, y2))
cropped.save(f"{output_dir}/page_005_table2.png")
记录渲染结果,包括:
以下清单供 layout-detective-agent 在逐页审查时参考。本技能不执行检查,仅提供指导框架。
paperfit run scripts/detect_column_void.py data/pages -o data/column_void_report.json,将机器投影结果与肉眼结论交叉验证Acknowledgements / References / Bibliography 的页上是否出现正文图表标题或正文浮动体?若有,按硬失败处理。source=pymupdf_native 的 B2 报告,对照页图检查 width_context、object_width_ratio 和 bbox 是否合理。booktabs 风格。width_context=column|page 只能作为辅助判断。orchestrator-agent 在编译成功后调用本技能。layout-detective-agent 使用页图进行视觉缺陷检测。quality-gatekeeper-agent 使用页图进行最终验收对比。code-surgeon-agent 在修复后可能请求局部页图验证特定修改。| 异常情况 | 处理方式 |
|---|---|
| Poppler 未安装 | 返回明确错误信息,包含安装指引 |
| PDF 文件损坏 | 报告错误,请求重新编译 |
| 部分页渲染失败 | 记录失败页码,尽可能渲染其余页,状态标记为 partial |
| 磁盘空间不足 | 报告错误,清理临时目录或提示用户释放空间 |
Visual Inspector Skill 就绪。
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub openraiser/paperfit --plugin paperfit9 skills in this plugin
/consistency-polisherInspect and repair local table, figure, and caption presentation while preserving content and venue formatting./float-optimizerPaperFit advice for LaTeX figure/table placement, width, clustering and breakable-table flow, verified against current page images./overflow-repairPaperFit overflow repair expertise for LaTeX paper layout./paperfitDiagnose and repair LaTeX paper layout through PaperFit's structured visual closed loop over rendered pages, source-grounded repairs, and visual verification. Use for overflowing figures or tables, float placement, readability, and submission page budgets./space-util-fixerPaperFit space util fixer expertise for LaTeX paper layout./taxonomy-vtoPaperFit taxonomy vto expertise for LaTeX paper layout.Other plugins' skills for the same job