ts-figure-optimize
The suite's SOLE figure vectorizer: turn ONE raster scientific figure (a PNG/JPG, e.g. a gpt-image-2 schematic) into an editable, publication-ready figure via DrawAI's **key-free HYBRID** — local perception (SAM3 region detection + PaddleOCR + Box-IR layout, no account) then a deterministic hybrid b…
Install / Use
npx skills add Spark-To-Paper-Skills/spark-to-paper-skills --skill ts-figure-optimizeInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
AI & Machine LearningSupported Platforms
Our assessment of ts-figure-optimize
ts-figure-optimize scores 93/100 on our quality scale, 255th of 950 AI & Machine Learning skills we index (top 27%).
Its SKILL.md is 20 KB long, well organised into 15 sections with 5 code examples: a thorough specification that gives an agent plenty to work with.
With 1,126 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 3 months ago, so ts-figure-optimize is actively maintained.
- Our last check on 2026-10-26 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-08. Automated pattern scan on 2026-10-08. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
ts-figure-optimize compared with similar skills
All 4 of these similar skills score higher than ts-figure-optimize; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| ts-figure-optimize (this skill)by Spark-To-Paper-Skills | 93 | 1.1k | 3mo ago | SKILL.md |
| claude-memby thedotmack | 100 | 117.6k | today | CLAUDE.md |
| taste-skillby Leonxlnx | 100 | 116.8k | 8d ago | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 92.8k | 1d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 79.8k | today | CLAUDE.md |
Frequently asked questions
- How do I install ts-figure-optimize?
- Run
npx skills add Spark-To-Paper-Skills/spark-to-paper-skills --skill ts-figure-optimize. The install tabs above show the steps for each supported agent. - Which AI agents does ts-figure-optimize work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is ts-figure-optimize safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is ts-figure-optimize still maintained?
- The repository was last updated about 3 months ago, so ts-figure-optimize is actively maintained.
Skill content
View source on GitHubname: ts-figure-optimize description: > The suite's SOLE figure vectorizer: turn ONE raster scientific figure (a PNG/JPG, e.g. a gpt-image-2 schematic) into an editable, publication-ready figure via DrawAI's key-free HYBRID — local perception (SAM3 region detection + PaddleOCR + Box-IR layout, no account) then a deterministic hybrid build that keeps the approved render pixel-exact (a whole-canvas raster) and lays an editable <text> overlay on top (~0.91 SSIM), exported as a self-contained SVG + vector PDF + an editable PPTX. The render's full richness is preserved EXACTLY (it IS the approved image) while every label becomes editable. The original raster is always kept. Hybrid is the ONLY mode used: there is no Codex full-vector redraw (legacy/off — it needs an account, and a redraw of a dense figure loses fidelity) and no Claude-redraw fallback. If this runtime cannot be provisioned, the caller keeps the approved PNG as-is — never a lossy redraw. Independent of the paper pipeline — give it any figure image.
ts-figure-optimize — raster figure → editable HYBRID, the key-free DrawAI path
This is the suite's only figure vectorizer, and it runs DrawAI's key-free HYBRID: SAM3 segments
the layout and PaddleOCR reads the text locally (on a GPU box, no Claude/Codex account), then a
deterministic build keeps the approved render pixel-exact and lays an editable <text> overlay
on top — exported as a self-contained SVG + vector PDF + editable PPTX (~0.91 SSIM; ~63 editable text
boxes on the test figure). The figure's richness is preserved EXACTLY (the graphics ARE the approved
render) while every label becomes editable.
Hybrid is the ONLY mode used. The engine also contains a legacy Codex full-vector redraw
(run_reconstruction.py) — it is off: it needs an LLM account, and a full redraw of a dense figure
measurably loses fidelity vs the exact render (~0.67 vs 0.91 SSIM). So the suite rule is HYBRID, or
else keep the approved PNG — never redraw.
It does NOT just embed the bitmap into a slide: it reads every label and re-lays it as editable text over the exact render. The genuinely complex graphics stay as the render raster (that is the point — pixel-exact richness), not a lossy trace.
When to use
You have a single raster figure (e.g. an approved gpt-image schematic) and want it editable without losing any richness. Input: a PNG/JPG path. If the DrawAI runtime can't be provisioned, the caller keeps the approved PNG as-is — there is no lightweight redraw fallback.
Absorbed dependency: DrawAI is VENDORED here (manual updates)
The DrawAI source (~5 MB, includes the MPS guard fix) is vendored inside this skill at
engine/ — so the skill is self-contained for code and needs no separate DrawAI checkout. The
heavy runtime is NOT vendored: ~4 GB model weights (SAM3/PaddleOCR/RMBG) + a runtime venv are
provisioned on deploy by scripts/setup_drawai.py (below). The orchestrator points at engine/ by
default (override with --drawai-repo/DRAWAI_REPO). Updates are manual — re-vendor engine/
from upstream DrawAI yourself when you want a newer version (see references/drawai_adapter.md; the
vendored commit is recorded in engine/ENGINE_VERSION.txt).
Deploy the runtime (once per machine): scripts/setup_drawai.py
The model runtime (SAM3 / PaddleOCR / RMBG weights + venv, ~8 GB) is deployed inside this skill at
ts-figure-optimize/engine/.local/drawai_runtime/ (gitignored — code is in git, the multi-GB weights are
provisioned on disk under the skill, never committed). It is self-contained under spark-to-paper-skills,
not borrowed from any outer checkout. run_hybrid.py AUTO-DEPLOYS it before running if it's missing,
so you normally don't call setup manually — but you can:
python scripts/setup_drawai.py --device cpu # download ~4GB models + build the runtime venv (under the skill)
python scripts/setup_drawai.py --check-only # verify the runtime is ready (drawai doctor)
python scripts/setup_drawai.py --reuse-runtime <path> # reuse an existing .local/drawai_runtime (skip download)
It tries DrawAI's official setup local first, and falls back to the validated manual install (paddle
from PyPI, CPU torch, openai-codex via pypi.org/simple, editable engine + runtime deps, sam3, triton)
when the official bootstrap can't reach its indexes. (Codex auth is needed ONLY for the legacy pure-A
redraw — the HYBRID path below is key-free.)
✅ VERIFIED key-free GPU recipe — ModelScope, NO HF token (validated 2026-06-23 on a 6×A40 box). The
HYBRID path needs no LLM key at all; models come from ModelScope (default --source modelscope,
which is NOT gated — this is why no HF_TOKEN is required):
pip install uv(any env), thenpython scripts/setup_drawai.py --device gpu→ builds the runtime venv (Python 3.12, torch+cu12x, paddlepaddle CPU) and downloadssam3.pt(~3.3 GB) / RMBG-2.0 / PP-OCRv5 from ModelScope. No HF_TOKEN, no Codex login for the hybrid. (~13 GB on disk underengine/.local/.)- Known fixes (now baked into the scripts; apply by hand only if you re-vendor an older engine):
- PaddleOCR ModelScope download can be 0-byte (
PaddlePaddle/PP-OCRv5_*is empty on ModelScope). If<runtime>/models/paddlex/official_models/PP-OCRv5_server_{det,rec}/inference.pdiparamsare missing, copy them from PaddleOCR's standard cache (it fetches them on first use):cp -rn ~/.paddlex/official_models/PP-OCRv5_server_{det,rec} <runtime>/models/paddlex/official_models/. - Device: the pinned paddle wheel is CPU-only — on a GPU box use
--device gpu;run_hybrid.pynow maps SAM3/RMBG→cudaand paddle→cpuautomatically. - Host build deps:
pip install python-pptx cairosvg numpy Pillowinto the interpreter that runsbuild_hybrid_pptx.py(it uses the HOST python, not the runtime venv). drawai doctorflags Chrome + Codex auth missing — IGNORE for the hybrid (those are only for the legacy pure-A redraw; the hybrid uses cairosvg + no LLM).
- PaddleOCR ModelScope download can be 0-byte (
- Run key-free:
python scripts/run_hybrid.py --image fig.png --run-name <n> --device gpu --no-text-gpt(--no-text-gptskips the only optional LLM step — GPT text-correction; have Claude do that per-region text correction instead if you want OCR subscript/case fixes, keeping the whole flow key-free).
Prerequisites (verify first)
- DrawAI runtime ready:
python scripts/setup_drawai.py --check-only→doctor: OK. If not:python scripts/setup_drawai.py --device cpu(provisions the vendoredengine/: downloads SAM3/PaddleOCR/RMBG ~4 GB + builds the runtime venv). The DrawAI source is already vendored atengine/(no separate checkout needed). - Codex/OpenAI auth present (
~/.codex/auth.jsonorOPENAI_API_KEY) — DrawAI's SVG/run0 agent (gpt-5.5) needs it. (Measured comparison showed Codex/gpt-5.5 outperforms a Claude-CLI agent for this generation task, so Codex is the engine here.) - A real PPTX renderer (LibreOffice
soffice) enables the PPTX render gate; if absent the PPTX render isNOT_RUNand the run cannot auto-PASS (still produces SVG/PPTX/PDF).
The orchestration (DEFAULT): scripts/run_hybrid.py — Codex-free preprocessing + HYBRID export
This is the production path. It was validated head-to-head against pure-A on the same fresh run: HYBRID ≈ 0.91 SSIM vs pure-A ≈ 0.67, and it is much cheaper because it SKIPS the Codex vector redraw entirely. One figure:
python scripts/run_hybrid.py --image <figure.png> --run-name <name> [--runs-root runs] [--device cpu] \
[--runtime-root .local/drawai_runtime] [--no-text-gpt]
Flow:
- DrawAI dry-run scaffold (config + run dir, no models).
- Codex-FREE IR stages in the runtime venv (
run_preprocess_ir.py: prepare → SAM3 → OCR → Box-IR). - GPT per-region text correction (
verify_text_gpt.py) — fixes OCR-dropped subscripts/case. - HYBRID build (
build_hybrid_pptx.py): pixel-exact graphics raster + editable text boxes (real sub/superscripts) →final/editable_hybrid.{pptx,pdf,svg}. - Editability verification.
Output under
runs/<name>/:source/source.png,ir/(box_ir + ocr),final/editable_hybrid.*,comparisons/(corrected_texts.json, hybrid_report.json, pptx_hybrid.json).
- Honest ceiling: only TEXT is editable; graphics stay raster. ~0.90 SSIM (re-typed text can't beat font/AA/sub-pixel). For a fully-vector-editable figure instead, use the LEGACY pure-A flow below.
LEGACY (isolated, NOT default): pure-A vector redraw — scripts/run_reconstruction.py
Kept for the rare case where you need every element (incl. graphics) as editable vector, accepting the lower fidelity (~0.67–0.8) and the Codex cost. It runs the full DrawAI Codex redraw + measured loop. Do NOT use it as the default — the hybrid flow above is better and cheaper.
python scripts/run_reconstruction.py --image <fig.png> --run-name <name> --device cpu --max-rounds 10 [--no-repair]
It drives DrawAI's full pipeline (normalize → SAM3 → OCR → Box-IR → classify → Codex SVG → validate →
native PPTX), then a measured best-of-rounds loop (SSIM/region/OCR/formula + RASTER_BACKGROUND_MATCH /
WAVEFORM_STYLE gates). Output: svg/semantic.svg, pptx/editable.pptx, pdf/publication_figure.pdf.
Stage R — structural-defect refinement (精修, model-judged, iterate a few rounds)
After the base reconstruction, run a targeted refinement loop whose goal is structural/logical correctness, NOT pixel-identity. Fonts, anti-aliasing, and exact colours MAY differ (that gap is accepted and unfixable for an editable redraw). What MUST be fixed: wrong/missing/extra arrows or reversed data-flow, misalignment, wrong relative positions of panels/icons/pictures, inconsistent / wrong / missing / duplicated icons, and any incoherence vs the original.
Loop (Claude is the judge+editor; the scripts are guides — edits are on the SVG master = the PPTX shapes 1:1, then the PPTX is re-exported):
1. render the current SVG (scripts/render_svg.py)
2. PER-REGION VISION COMPARE (the core — metrics CANNOT see semantic defects):
AUTOMATED: scripts/vision_region_diff.py sends each region's [SOURCE | RENDER] pair (upscaled) to a
vision model (gpt-5.5; OpenAI-compatible, key from ~/.codex/auth.json) and writes a structured
comparisons/vision_defects.json with the defect categories below. Use a GRID (`--grid 3/4`) so cells
span ADJACENT elements (inter-element overlaps like matrix-vs-colourbar are only visible across a
boundary; tight per-element Box-IR crops miss them). Do NOT pass temperature (gpt-5.5 rejects it).
MANUAL fallback: scripts/region_crops.py emits the same pairs for the skill executor (Claude) to READ
and emit the same JSON by hand. Either way, judge each region against this SEMANTIC checklist
(ignore font/AA/colour-shade):
- text OVERFLOWING / spilling outside its box or panel
- any element OVERLAPPING/colliding with another (arrow over a figure; matrix over its colourbar)
- WRONG ICON semantics (a cycle/loop ↻ drawn as a straight arrow; ↔ drawn as →; garbled icon)
- MISALIGNED / unevenly-sized repeated shapes (encoder bars, rows, badges)
- MISSING / DUPLICATED / wrongly-POSITIONED elements vs source
(scripts/diff_overlay.py heatmap + scripts/compare_regions.py SSIM only say WHERE to look first.)
3. Build the defect list from the per-region vision pass (NOT from SSIM — SSIM misses all of the above).
4. FIX — two strategies per defect:
(a) VECTOR surgical edit (preferred, stays editable): redirect/add/remove an arrow, add a marker-end
arrowhead, move/resize a box so text fits, shift the colourbar/label off the matrix, align the bars.
(b) RASTER-CROP-EMBED fallback (when a shape/icon is too complex to redraw faithfully — e.g. an
intricate lo
Truncated for display — read the full file on GitHub.
Related Skills
claude-mem
117.6kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
taste-skill
116.8kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
Understand-Anything
92.8kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
79.8kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
