sci-figure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSci-Figure — Scientific Figure Extractor
Sci-Figure — 学术图表提取工具
Precisely extract figures and sub-figures from academic PDF papers.
精准提取学术PDF论文中的图表及子图。
Installation
安装
Install the package from the skill directory before first use:
bash
cd ${SKILL_DIR}
pip install -e .This registers the CLI command. Requires Tesseract OCR:
sh-sci-fig- Windows:
winget install UB-Mannheim.TesseractOCR - Linux:
apt install tesseract-ocr - macOS:
brew install tesseract
首次使用前,从技能目录安装该包:
bash
cd ${SKILL_DIR}
pip install -e .此操作会注册 CLI命令。需要安装Tesseract OCR:
sh-sci-fig- Windows:
winget install UB-Mannheim.TesseractOCR - Linux:
apt install tesseract-ocr - macOS:
brew install tesseract
Preferences (EXTEND.md)
偏好设置(EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
bash
undefined使用Bash检查EXTEND.md文件是否存在(优先级顺序):
bash
undefinedCheck project-level first
先检查项目级目录
test -f .baoyu-skills/sci-figure/EXTEND.md && echo "project"
test -f .baoyu-skills/sci-figure/EXTEND.md && echo "project"
Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
再检查用户级目录(跨平台:$HOME适用于macOS/Linux/WSL)
test -f "$HOME/.baoyu-skills/sci-figure/EXTEND.md" && echo "user"
**EXTEND.md Supports**: Default DPI | Default output format | Tesseract pathtest -f "$HOME/.baoyu-skills/sci-figure/EXTEND.md" && echo "user"
**EXTEND.md支持配置**:默认DPI | 默认输出格式 | Tesseract路径Usage
使用方法
bash
sh-sci-fig <input.pdf> [options]bash
sh-sci-fig <input.pdf> [options]Options
选项
| Option | Short | Description | Default |
|---|---|---|---|
| PDF file path | Required | |
| | Figure number (1, 2, 3...) | Required (except --list/--all) |
| | Sub-figure label (a, b, c...) | None (returns whole figure) |
| | Output directory | Current directory |
| | Output resolution | 600 |
| | List all available figure numbers | false |
| Extract all figures | false | |
| Output format (png/jpg) | png | |
| | Suppress info messages | false |
| 选项 | 缩写 | 描述 | 默认值 |
|---|---|---|---|
| PDF文件路径 | 必填 | |
| | 图表编号(1, 2, 3...) | 必填(--list/--all除外) |
| | 子图标签(a, b, c...) | 无(返回完整图表) |
| | 输出目录 | 当前目录 |
| | 输出分辨率 | 600 |
| | 列出所有可用的图表编号 | false |
| 提取所有图表 | false | |
| 输出格式(png/jpg) | png | |
| | 抑制信息提示 | false |
Examples
示例
bash
undefinedbash
undefinedExtract Figure 2, sub-figure c
提取第2号图表的c子图
sh-sci-fig paper.pdf -f 2 -s c
sh-sci-fig paper.pdf -f 2 -s c
Extract entire Figure 3
提取完整的第3号图表
sh-sci-fig paper.pdf -f 3
sh-sci-fig paper.pdf -f 3
List all available figures in a PDF
列出PDF中所有可用的图表
sh-sci-fig paper.pdf --list
sh-sci-fig paper.pdf --list
Extract all figures
提取所有图表
sh-sci-fig paper.pdf --all
sh-sci-fig paper.pdf --all
Custom output directory and DPI
自定义输出目录和DPI
sh-sci-fig paper.pdf -f 2 -s c -o ./output/ -d 300
**Output**:Extracted: figure_2c.png (1920x1080, 600 DPI)
undefinedsh-sci-fig paper.pdf -f 2 -s c -o ./output/ -d 300
**输出示例**:Extracted: figure_2c.png (1920x1080, 600 DPI)
undefinedError Handling
错误处理
| Scenario | Behavior |
|---|---|
| Figure number not found | Error + list all available figure numbers |
| OCR recognition failed | Return entire figure region |
| Sub-figure split failed | Return entire figure region |
| No sub-figure labels found | Return entire figure region |
| 场景 | 行为 |
|---|---|
| 未找到指定图表编号 | 报错并列出所有可用的图表编号 |
| OCR识别失败 | 返回完整图表区域 |
| 子图分割失败 | 返回完整图表区域 |
| 未找到子图标签 | 返回完整图表区域 |
Tech Stack
技术栈
| Library | Role |
|---|---|
| pdfplumber | Text + coordinate extraction (locate "Figure X" labels) |
| PyMuPDF (fitz) | PDF → high-quality image rendering (600 DPI) |
| opencv-python | Boundary detection, contour analysis |
| Pillow | Final cropping, format conversion |
| pytesseract | OCR for sub-figure label recognition |
| 库 | 作用 |
|---|---|
| pdfplumber | 文本与坐标提取(定位"Figure X"标签) |
| PyMuPDF (fitz) | PDF转高质量图片渲染(600 DPI) |
| opencv-python | 边界检测、轮廓分析 |
| Pillow | 最终裁剪、格式转换 |
| pytesseract | 子图标签识别OCR |
Detected Figure Fields
检测到的图表字段
| Field | Type | Description |
|---|---|---|
| int | Figure number |
| int | Page index (0-based) |
| tuple | Crop region in pixels |
| tuple | Crop region in PDF points |
| str | Caption text (truncated to 200 chars) |
| str | Full caption text (no truncation) |
| tuple | Caption bounding box in PDF points |
| list[str] | Sub-figure labels, e.g. |
| list[dict] | Labels with detected format, e.g. |
| str | One of: |
| bool | True for |
| ndarray | Cropped figure image (numpy array) |
| 字段 | 类型 | 描述 |
|---|---|---|
| int | 图表编号 |
| int | 页码索引(从0开始) |
| tuple | 像素裁剪区域 |
| tuple | PDF坐标裁剪区域 |
| str | 图表标题文本(截断至200字符) |
| str | 完整图表标题文本(不截断) |
| tuple | PDF坐标下的标题 bounding box |
| list[str] | 子图标签,例如 |
| list[dict] | 带格式的标签信息,例如 |
| str | 类型包括: |
| bool | 对于 |
| ndarray | 裁剪后的图表图片(numpy数组) |
Extension Support
扩展支持
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md进行自定义配置。有关路径和支持选项,请查看偏好设置部分。
© License & Copyright
© 许可协议与版权
Aut_Sci_Write — Autonomous Scientific Writer
- Author: Shuo Zhao
- License: MIT License
- Copyright: © 2026 Shuo Zhao. All rights reserved.
- Original Work: This is an original work created by the author. No reproduction, redistribution, or commercial use without explicit permission. Permission is hereby granted, free of charge, to any person obtaining a copy of this software... (See the LICENSE file in the root directory for the full MIT terms.)
This skill is part of the Aut_Sci_Write suite. For full license terms, see the LICENSE file in the project root.
Aut_Sci_Write — 自主学术写作工具套件
- 作者:Shuo Zhao
- 许可协议:MIT License
- 版权:© 2026 Shuo Zhao。保留所有权利。
- 原创声明:本作品为作者原创。未经明确许可,不得复制、分发或用于商业用途。 特此免费授予任何获得本软件副本的人...(完整MIT条款请查看根目录下的LICENSE文件。)