mcpField
S
sci-figure

sci-figure

github.com/shzhao27208Documents213235 installsUpdated 11w ago
Repository

About sci-figure

sci-figure is a command-line skill for extracting figures and sub-figures from academic PDFs. It combines native image extraction, computer-vision detection, and caption-based fallback, with OCR options for identifying sub-figure labels.

Key features

  1. 01List or extract selected or all figures
  2. 02Crop labeled sub-figures
  3. 03Hybrid native, CV, and caption strategies
  4. 04Choose output format, resolution, and OCR
  5. 05Render and annotate PDF pages

Use cases

  1. 01Saving a figure from a research PDF
  2. 02Extracting one panel from a composite figure
  3. 03Reviewing detected crop regions on a page

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/shzhao27208/aut_sci_write --skill sci-figure

After installing, type/sci-figurein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

_meta.json
CHANGELOG.md
LICENSE
README_CN.md
README.md
requirements.txt
setup.py
sci_figure.egg-info/
dependency_links.txt
entry_points.txt
PKG-INFO
requires.txt
SOURCES.txt
top_level.txt
sci_figure/
__init__.py
annotator.py
caption_detector.py
cli.py
column_detector.py
exceptions.py
figure_extractor.py
image_processor.py
native_extractor.py
pdf_parser.py
region_detector.py
subfigure_splitter.py
utils.py
scripts/
extract_figure.py
tests/
__init__.py
test_caption_dedup.py

Details

From the project README

Sci-Figure — Scientific Figure Extractor

Precisely extract figures and sub-figures from academic PDF papers.

License note: sci-figure is licensed under AGPL-3.0-or-later because it links PyMuPDF (fitz), which is AGPL-licensed.

Installation

Install the package from the skill directory before first use:

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

Preferences (EXTEND.md)

Use Bash to check EXTEND.md existence (priority order):

# Check project-level first
test -f .baoyu-skills/sci-figure/EXTEND.md && echo "project"

# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.baoyu-skills/sci-figure/EXTEND.md" && echo "user"

EXTEND.md Supports: Default DPI | Default output format | Tesseract path

Usage

sh-sci-fig <input.pdf> [options]

Options

OptionShortDescriptionDefault
<input>PDF file pathRequired
--figure-fFigure number (1, 2, 3...)Required (except --list/--all)
--subfigure-sSub-figure label (a, b, c...)None (returns whole figure)
--output-oOutput directoryCurrent directory
--dpi-dOutput resolution600
--list-lList all available figure numbersfalse
--allExtract all figuresfalse
--formatOutput format (png/jpg)png
--strategyExtraction strategy: hybrid/native/cvhybrid
--ocrOCR engine: tesseract/easyocr/nonetesseract
--render-pageRender full page with annotationsfalse
--annotateDraw bounding boxes on rendered pagefalse
--bboxManual bbox override (x0,y0,x1,y1 in px)None
--no-trimDisable whitespace trimmingfalse
--debugEnable debug loggingfalse
--quiet-qSuppress info messagesfalse

Examples

# Extract Figure 2, sub-figure c
sh-sci-fig paper.pdf -f 2 -s c

# Extract entire Figure 3
sh-sci-fig paper.pdf -f 3

# List all available figures in a PDF
sh-sci-fig paper.pdf --list

# Extract all figures
sh-sci-fig paper.pdf --all

# Custom output directory and DPI
sh-sci-fig paper.pdf -f 2 -s c -o ./output/ -d 300

# Use EasyOCR for sub-figure label detection
sh-sci-fig paper.pdf --all --ocr easyocr

# CV-only strategy (skip native extraction)
sh-sci-fig paper.pdf --all --strategy cv

# Render page with annotated bounding boxes (debugging)
sh-sci-fig paper.pdf -f 1 --render-page --annotate

# Manual bbox extraction (multimodal correction)
sh-sci-fig paper.pdf -f 1 --bbox 100,200,800,1200

Output:

Extracted: figure_2c.png (1920x1080, 600 DPI)

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

Tech Stack

LibraryRole
pdfplumberText + coordinate extraction (caption detection)
PyMuPDF (fitz)Native image extraction + high-quality page rendering
opencv-pythonCV region detection, connected-component analysis, content validation
PillowFinal cropping, format conversion
pytesseractOCR for sub-figure label recognition (default)
easyocrAlternative OCR engine (optional, pip install sci-figure[ocr])
numpyImage array operations

Extraction Engines (v2)

EnginePriorityBest For
Native (PyMuPDF)1stRaster images embedded in PDF
CV (connected-component)2ndVector graphics, colored plots
Caption-anchored3rdFallback when above engines fail

The hybrid strategy (default) tries all three in order and validates results.

Detected Figure Fields

Each figure returned by FigureExtractor.detect_all() is a dict with these keys:

FieldTypeDescription
numberintFigure number
pageintPage index (0-based)
bbox_pdftupleCrop region in PDF points (x0, y0, x1, y1)
bbox_pxtupleCrop region in pixels (x0, y0, x1, y1)
caption_textstrFull caption text
figure_typestrOne of: figure, scheme, chart, supplementary, extended_data
sublabelslist[str]Sub-figure labels, e.g. ["a","b","c"]
imagendarrayCropped figure image (numpy array)
engine_usedstrEngine that produced the crop: native, cv, or fallback

list_figures() returns the same dicts without the image field.

Extension Support

Custom configurations via EXTEND.md. See Preferences section for paths and supported options.


© 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.

Comments

Markdown supported