ky_ppt
Image → editable PPTX / AI, fully local zero-cost. Three-tier architecture:
- Geometry Engine (
--engine): Default vtracer (vectorize_vtracer.py, Rust O(n) color stacking + spline fitting, smooth curves, gradient fidelity); Optional opencv (vectorize_local.py, two-stage palette quantization + contours, suitable for pure flat color blocks, use--merge-colorsfor minimal shapes). - Text/Semantic Layer (optional): Default RapidOCR (
ocr_manifest.py,--ocr-manifest, CPU seconds) for precise OCR + text positioning, automatically generates text-manifest, eliminating manual coordinate recording; Optional local Ollama small VLM (vlm_semantics.py, default qwen3-vl:2b) for short semantic tasks like region/title (--mode regions). Note: 2B-level VLM is unstable for dense image character-level bbox OCR; prefer RapidOCR for precise text manifest. - Drawing Backend: Built-in drawing backend (MIT, see LICENSE), geometry + text manifest → native editable PPTX/AI.
Standard Workflow (Research Figures with Text)
- Text Manifest (choose one of three):
- Automatic OCR (recommended): Add
--ocr-manifestin step 3. RapidOCR will accurately identify text + bboxes on the original image with text, automatically generatingtext-manifest.json(CPU seconds, auto-estimates font size/color). If geometry uses a de-texted image, first runocr_manifest.py --input-image original.png --output text-manifest.jsonseparately, then pass it via--text-manifestto avoid text being baked in twice. - Automatic VLM (short semantics): With local Ollama running and
ollama pull qwen3-vl:2b, add--vlm-manifest(CPU minutes, suitable for short text like titles/regions; less reliable than RapidOCR for dense character-level OCR). - Manual: Read references/text-workflow.md. Record each text's content, pixel coordinates (y is baseline), font size, and color into
text-manifest.json(schema_version "1.0", source_canvas as original image width/height, coordinate_space "pixels").
- Automatic OCR (recommended): Add
- De-text: Use any available image editing model to clear only the text (including watermarks), obtaining a cleaned image. Verify against the original that shapes, layout, colors, lines, and canvas remain unchanged; re-run cleanup if they changed.
- Local Reconstruction (zero cost, no payment confirmation needed):
py -3 -X utf8 <skill>/scripts/run_local.py --input-image cleaned.png --text-manifest text-manifest.json --output-root <output directory> --application ppt
-
Default
--engine vtracer(better curves/colors); for pure flat color blocks desiring minimal shape count, use--engine opencv --merge-colors. -
Without a manual manifest, add
--ocr-manifest(recommended, RapidOCR) or--vlm-manifest(Ollama) for automatic generation. -
Use the original resolution from the de-text model, do not downscale beforehand (fine lines and small details will blur). If the resolution differs from the original image, the manifest's source_canvas should still use the original size; coordinates are automatically mapped proportionally.
-
Text layer order is forced on top by code; no need to manually ensure paint_order in the manifest.
-
Output:
<output directory>\shibielujingN\shibielujingN.pptx(native editable shapes + text boxes), same directory retains master SVG, geometry cache, and text-manifest.json.
- Validation: Use python-pptx to count freeform/text box counts; visually check by exporting PNG from PowerPoint COM and comparing with original. For white canvas issues, first read references/white-overlay-diagnostics.md.
For images without text: skip steps 1-2 and go directly to step 3. For an already approved SVG: use scripts/run_from_svg.py --input-svg ....
PDF → Research Presentation PPT (pdf_to_deck branch)
Organizes a PDF into a set of white-background academic blue presentation PPTs, independent of the "single image → editable shapes" pipeline above.
- Entry
scripts/pdf_to_deck.py: PyMuPDF extracts title/sections/paragraphs/embedded images/tables → outline → python-pptx academic template output (cover / table of contents / section page / key points page / results page / summary). - Multi-panel Splitting
scripts/split_panels.py: White-space projection cuts A/B/C/D composite figures into individual panels by row/column; RapidOCR only helps identify panel letters; if unrecognized, panels are numbered by row/column order. Panels must be separated by white space/blank space. Splitting is only for grouping into cards; never use one image per page. - Default Style (learned and frozen from user references): Deep purple literature review style (main color
#7D2E68, light purple#F3E8F2, white background), see references/deck-style-guide.md for details. Main slide types:- evidence slide: Deep purple full-width title bar + white circle numbered badge + white theme word → bold black leading sentence (keywords emphasized in purple) → 1–3 side-by-side evidence cards (purple background white text keyword label + full multi-panel composite figure + light purple conclusion bar) → bottom light purple summary bar (process-style "loading → migration → targeting → treatment" or sample size/measurement).
- limitations slide: Arrow-shaped purple label + "Had: … (black) / Yet-to-prove: … (purple)" contrasting lines.
- Titles must be conclusion-type with numbers (e.g., "Infarct volume reduced by 26.7%"), retain qualifiers like "not quantified / still pending".
- Image/Text Rules: Card composite figures embedded as bitmaps, scaled proportionally without cropping;
--vectorize-figuresis a reserved hook for future conversion of panels via vtracer into editable shapes. - Outline Source:
--outline outline.json: Assistant fills in a refined outline (titles/key points/figure captions/speaker notes) after reading the PDF; best quality;- Without
--outline: Offline fallback extracts sentences per section, faithful but dry.
# Offline fallback: PDF direct output
py -3 -X utf8 scripts\pdf_to_deck.py --pdf paper.pdf --output out\deck.pptx
# Assistant outline-driven: First write outline.json, then output
py -3 -X utf8 scripts\pdf_to_deck.py --outline outline.json --output out\deck.pptx
Outline schema (v1.0): {"title","authors","color":{"primary",...},"slides":[{"type":"cover|toc|section|content|evidence|limitations|result|figure|table|conclusion","title","bullets","image","image_caption","table","notes"}]}.
evidence slide: {"type":"evidence","number","title","lead","cards":[{"label","image","caption"}],"summary"};
limitations slide: {"type":"limitations","number","title","cards":[{"label","have","todo"}]}.
When writing the outline, the assistant should semantically group panels of the same argument into the same card, and extract keyword labels and concluding short sentences for each card.
Limitations: Long papers' key point refinement depends on the assistant/LLM; the pure offline sentence extraction does not polish; complex color images and densely packed panels without white space separation have limited splitting performance.
Illustrator Branch
--application ai. Requires local installation of Illustrator and opening the target document (Windows COM / macOS AppleScript),
see references/illustrator-workflow.md for details.
If not installed, use scripts/run_illustrator.py --dry-run to verify geometry, or instruct the user to open the master SVG in Illustrator and save as .ai.
Quality Tuning
--preset auto|flat|dense: Auto-selects parameters.autodecides based on detail density and number of colors; Useflat(24 colors) for flat color block schematics, anddense(128 colors, min-area 0.5, epsilon 0.3) for dense research flowcharts/small bitmap images. Explicit--max-colors/--min-area/--epsilon/--fit-toloverride presets.--max-colors(default 24, max 256): Use 96-128 for complex images/gradient backgrounds--min-area(default 6 px²): Reduce to 0.5-2 for broken thin lines--epsilon(default 0.6 px): Smaller values yield finer detail--no-smooth: Output pure polylines--merge-colors: Merges same-color regions into single composite paths. Reduces PPT shape count from tens of thousands to approximately the number of colors (~130), making open/edit smoother; cost is editing by color rather than by individual element. Recommended for dense images delivered as PPT.- Small images (longest side <1600px): Engine automatically 2x upsamples, vectorizes, then scales coordinates back to original canvas to avoid losing 1px strokes.
Quality Gate (Must Run Before Delivery)
py -3 -X utf8 <skill>/scripts/check_quality.py --svg out.svg --source original.png
Renders back and compares to source, outputs mae and ink_recall (dark ink recall, whether text/fine lines are lost).
Only deliver when ok:true; low ink_recall indicates lost text, re-run with parameter adjustments per suggestions.
Renderer prefers resvg-js (npm install --prefix <skill> @resvg/resvg-js, automatically installed by setup.ps1),
fallback svglib (may underestimate fidelity for complex paths; its WARN messages are for reference only).
Constraints & Security
- SVG Contract: Pure vector, stable IDs, viewBox=canvas, composite paths retain cutouts (nonzero), bottom-to-foreground order;
No gradients/CSS/raster/use.
validate_vector_svg.pyperforms automatic validation. - Input Protection: Only PNG/JPEG/WebP, ≤40MP; SVG containing
<!ENTITYis always rejected (entity expansion protection). - This skill contains no paid interfaces or network calls; do not ask for API keys.
- Dependencies: Python 3.11+, vtracer, rapidocr-onnxruntime (automatic text manifest), pymupdf (PDF parsing), opencv-python, numpy, Pillow,
python-pptx, fonttools, shapely, pypinyin, pywin32 (Windows). Install: run
setup.ps1from the repository root. - Optional semantic layer: Local Ollama +
ollama pull qwen3-vl:2b(can run on CPU, ~2GB); only needed for--vlm-manifest/region tasks. - Windows PowerPoint demo playback (optional):
scripts/run_ppt_path_playback.ps1, see references/powerpoint-workflow.md.