sci-figure

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sci-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
sh-sci-fig
CLI command. Requires Tesseract OCR:
  • Windows:
    winget install UB-Mannheim.TesseractOCR
  • Linux:
    apt install tesseract-ocr
  • macOS:
    brew install tesseract
首次使用前,从技能目录安装该包:
bash
cd ${SKILL_DIR}
pip install -e .
此操作会注册
sh-sci-fig
CLI命令。需要安装Tesseract OCR:
  • 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
undefined

Check 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 path
test -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

选项

OptionShortDescriptionDefault
<input>
PDF file pathRequired
--figure
-f
Figure number (1, 2, 3...)Required (except --list/--all)
--subfigure
-s
Sub-figure label (a, b, c...)None (returns whole figure)
--output
-o
Output directoryCurrent directory
--dpi
-d
Output resolution600
--list
-l
List all available figure numbersfalse
--all
Extract all figuresfalse
--format
Output format (png/jpg)png
--quiet
-q
Suppress info messagesfalse
选项缩写描述默认值
<input>
PDF文件路径必填
--figure
-f
图表编号(1, 2, 3...)必填(--list/--all除外)
--subfigure
-s
子图标签(a, b, c...)无(返回完整图表)
--output
-o
输出目录当前目录
--dpi
-d
输出分辨率600
--list
-l
列出所有可用的图表编号false
--all
提取所有图表false
--format
输出格式(png/jpg)png
--quiet
-q
抑制信息提示false

Examples

示例

bash
undefined
bash
undefined

Extract 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)
undefined
sh-sci-fig paper.pdf -f 2 -s c -o ./output/ -d 300

**输出示例**:
Extracted: figure_2c.png (1920x1080, 600 DPI)
undefined

Error Handling

错误处理

ScenarioBehavior
Figure number not foundError + list all available figure numbers
OCR recognition failedReturn entire figure region
Sub-figure split failedReturn entire figure region
No sub-figure labels foundReturn entire figure region
场景行为
未找到指定图表编号报错并列出所有可用的图表编号
OCR识别失败返回完整图表区域
子图分割失败返回完整图表区域
未找到子图标签返回完整图表区域

Tech Stack

技术栈

LibraryRole
pdfplumberText + coordinate extraction (locate "Figure X" labels)
PyMuPDF (fitz)PDF → high-quality image rendering (600 DPI)
opencv-pythonBoundary detection, contour analysis
PillowFinal cropping, format conversion
pytesseractOCR for sub-figure label recognition
作用
pdfplumber文本与坐标提取(定位"Figure X"标签)
PyMuPDF (fitz)PDF转高质量图片渲染(600 DPI)
opencv-python边界检测、轮廓分析
Pillow最终裁剪、格式转换
pytesseract子图标签识别OCR

Detected Figure Fields

检测到的图表字段

FieldTypeDescription
number
intFigure number
page
intPage index (0-based)
bbox
tupleCrop region in pixels
bbox_pdf
tupleCrop region in PDF points
caption
strCaption text (truncated to 200 chars)
caption_full
strFull caption text (no truncation)
caption_bbox_pdf
tupleCaption bounding box in PDF points
sublabels
list[str]Sub-figure labels, e.g.
["a","b","c"]
sublabel_details
list[dict]Labels with detected format, e.g.
{"label":"a","format":"(a)"}
figure_type
strOne of:
figure
,
scheme
,
chart
,
supplementary
,
extended_data
is_supplementary
boolTrue for
supplementary
and
extended_data
types
image
ndarrayCropped figure image (numpy array)
字段类型描述
number
int图表编号
page
int页码索引(从0开始)
bbox
tuple像素裁剪区域
bbox_pdf
tuplePDF坐标裁剪区域
caption
str图表标题文本(截断至200字符)
caption_full
str完整图表标题文本(不截断)
caption_bbox_pdf
tuplePDF坐标下的标题 bounding box
sublabels
list[str]子图标签,例如
["a","b","c"]
sublabel_details
list[dict]带格式的标签信息,例如
{"label":"a","format":"(a)"}
figure_type
str类型包括:
figure
,
scheme
,
chart
,
supplementary
,
extended_data
is_supplementary
bool对于
supplementary
extended_data
类型为True
image
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文件。

本技能是Aut_Sci_Write套件的一部分。完整许可条款请查看项目根目录下的LICENSE文件。