Skip to content

Agent skill that turns natural language, code, Terraform/K8s, SQL, OpenAPI, AsyncAPI, Protobuf and GraphQL sources into editable, tested draw.io architecture diagrams: incremental sync, multi-view projection, drift diff, CI architecture tests, whiteboard derasterize, interactive HTML/PPTX/Mermaid exports.

feat: drawio2pptx.py — export a diagram to a PowerPoint deck (v1.24.0) (#72)

Agents365.aiff879ea8ba4d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9dbbbd4..c327037 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@ All notable changes to **drawio-skill** are documented here. The format is based
on [Keep a Changelog](https://keepachangelog.com/), and the project follows
semantic-ish versioning (the `version:` field in `skills/drawio-skill/SKILL.md`).
+## [1.24.0] — 2026-07-03
+### Added
+- **Diagram → PowerPoint** (`scripts/drawio2pptx.py`) — export a (multi-page)
+ `.drawio` to a 16:9 `.pptx`, one page per slide, the page name as the slide
+ title and the diagram centred + scaled to fit. A C4 model
+ (Context / Container / Component) becomes a ready-to-present deck.
+ - `drawio2pptx.py c4.drawio -o c4.pptx`.
+ - Needs the draw.io CLI (page PNG export, `--page-index` is 1-based) and the
+ optional `python-pptx` package (graceful error if absent, same pattern as
+ PyYAML). Verified openable via LibreOffice + python-pptx.
+ - SKILL.md router + READMEs updated. Suite now 59.
+
## [1.23.0] — 2026-07-03
### Added
- **Diagram → Markdown** (`scripts/explain.py`) — the inverse of the generators:
diff --git a/README.md b/README.md
index b7889d2..7eb0d86 100644
--- a/README.md
+++ b/README.md
@@ -179,6 +179,9 @@ python3 scripts/timelapse.py src --importer pyimports # → architecture-evoluti
# Reverse: describe an existing .drawio as structured Markdown (README / PR summary)
python3 scripts/explain.py architecture.drawio -o architecture.md
+# Diagram → PowerPoint deck (one page per slide; C4 model → presentation)
+python3 scripts/drawio2pptx.py c4.drawio -o c4.pptx # needs: pip install python-pptx
+
# any extractor → auto-layout → editable .drawio
python3 scripts/autolayout.py graph.json -o diagram.drawio
```
@@ -189,6 +192,7 @@ python3 scripts/autolayout.py graph.json -o diagram.drawio
| **Diagram diff** | `drawiodiff.py` compares two `.drawio` (or two live snapshots) into one colour-coded graph — added=green, removed=red, changed=orange — so you can see architecture / infra **drift** at a glance |
| **Architecture time-lapse** | `timelapse.py` re-runs an importer across a repo's git history and assembles a self-contained HTML player — watch modules & edges appear over time (▶ play / ‹ › step) |
| **Diagram → Markdown** | `explain.py` reverses a `.drawio` into a structured description — components by tier, relations, per-page for C4 — for dropping an architecture summary into a README or PR |
+| **Diagram → PowerPoint** | `drawio2pptx.py` turns a multi-page diagram into a 16:9 deck (one page per slide, page name as title) — a C4 model becomes a ready-to-present slideshow |
| **Sequence engine** | `seqlayout.py` computes lifeline / activation-bar / arrow geometry from a message list — no Graphviz, no hand placement |
| **Auto-layout** | Graphviz places nodes and routes orthogonal edges *around* them — removes the manual-coordinate ceiling for large graphs. `--tune` tries both directions and keeps the more readable one |
| **Transitive reduction** | drops edges implied by a longer path, turning a dense hairball into a traceable graph (asyncio: 149 → 46 edges) |
diff --git a/README_CN.md b/README_CN.md
index d7062e8..92e2925 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -177,6 +177,9 @@ python3 scripts/timelapse.py src --importer pyimports # → architecture-evoluti
# 反向:把已有的 .drawio 描述成结构化 Markdown(README / PR 摘要)
python3 scripts/explain.py architecture.drawio -o architecture.md
+# 图 → PowerPoint 幻灯片(每页一张;C4 模型 → 演示稿)
+python3 scripts/drawio2pptx.py c4.drawio -o c4.pptx # 需要: pip install python-pptx
+
# 任一提取器 → 自动布局 → 可编辑的 .drawio
python3 scripts/autolayout.py graph.json -o diagram.drawio
```
@@ -187,6 +190,7 @@ python3 scripts/autolayout.py graph.json -o diagram.drawio
| **图对比 (diff)** | `drawiodiff.py` 把两张 `.drawio`(或两个实时快照)对比成一张彩色图 —— 新增=绿、删除=红、变更=橙 —— 一眼看出架构 / 基础设施**漂移** |
| **架构时间轴** | `timelapse.py` 沿 git 历史逐个提交重跑提取器,拼成一个自包含 HTML 播放器 —— 看着模块和依赖边随时间长出来(▶ 播放 / ‹ › 单步) |
| **图 → Markdown** | `explain.py` 把一张 `.drawio` 反向描述成结构化文档 —— 按层级列出组件、关系、C4 多页分节 —— 方便把架构摘要塞进 README 或 PR |
+| **图 → PowerPoint** | `drawio2pptx.py` 把多页图变成 16:9 幻灯片(每页一张、页名当标题)—— C4 模型一键变成可演示的 slideshow |
| **时序图引擎** | `seqlayout.py` 从消息列表直接算出 lifeline / 激活条 / 箭头几何 —— 不需要 Graphviz,不需要手摆 |
| **自动布局** | Graphviz 自动布点,正交连线**绕开**节点 —— 大图不再需要手动摆坐标。`--tune` 双向各排一次取更可读的 |
| **传递约简** | 删掉被更长路径蕴含的边,把密集的"毛线团"变成可读图(asyncio:149 → 46 条边) |
diff --git a/skills/drawio-skill/SKILL.md b/skills/drawio-skill/SKILL.md
index 429f0c4..56dd8c4 100644
--- a/skills/drawio-skill/SKILL.md
+++ b/skills/drawio-skill/SKILL.md
@@ -1,6 +1,6 @@
---
name: drawio-skill
-version: 1.23.0
+version: 1.24.0
description: Use when the user requests diagrams, flowcharts, architecture diagrams, ER diagrams, UML / sequence / class diagrams, network topology, cloud architecture from Terraform or Kubernetes manifests, ML/DL model figures (Transformer/CNN/LSTM), mind maps, or any visualization. Also use proactively when explaining systems with 3+ components, complex data flows, or relationships that benefit from visual representation. Best suited when the diagram needs custom styling, rich shape vocabulary, swimlanes, or exportable images (PNG/SVG/PDF/JPG). Generates .drawio XML and exports locally via the native draw.io desktop CLI.
license: MIT
homepage: https://github.com/Agents365-ai/drawio-skill
@@ -52,6 +52,7 @@ When the workflow references one of these, read it on demand — none of them ne
| `scripts/drawiodiff.py` | The user wants to **compare / diff two diagrams or two snapshots** ("what changed", infra drift) — `drawiodiff.py old.drawio new.drawio -o diff.json` emits a colour-coded graph (added=green, removed=red, changed=orange, same=grey) for autolayout. Matches by cell id (importer/live-snapshot output) or `--by-label` (hand-drawn) |
| `scripts/timelapse.py` | The user wants an **architecture time-lapse / to see how a codebase's structure evolved over git history** — `timelapse.py <dir> --importer pyimports` re-runs an importer at each sampled commit and assembles a self-contained HTML player (embedded frames, play/step controls). Best on a package with real import edges (point `<dir>` at the module root) |
| `scripts/explain.py` | The user wants to **describe / document / summarize an existing `.drawio` in words** (reverse of generating one) — `explain.py diagram.drawio` emits structured Markdown: components grouped by container/tier, relations (`A —label→ B`), per-page sections for multi-page/C4. Good for a README/PR summary or a text-only read-out |
+| `scripts/drawio2pptx.py` | The user wants a **PowerPoint deck / slides from a diagram** — `drawio2pptx.py diagram.drawio -o deck.pptx` puts each page on its own 16:9 slide (page name as title), so a multi-page **C4 model** becomes a ready-to-present deck. Needs `python-pptx` (`pip install python-pptx`) + the draw.io CLI |
| `scripts/sqlerd.py` | The user wants an **ER diagram from SQL DDL** — parses `CREATE TABLE` statements into per-table nodes (columns with PK/FK markers) and crow's-foot FK edges for autolayout |
| `scripts/seqlayout.py` | The user wants a **sequence diagram** — describe participants + messages as JSON and the script computes all lifeline/activation/arrow geometry deterministically (no hand-placed coordinates, no Graphviz needed) |
| `scripts/c4.py` | The user wants a **C4 model** (System Context / Container / Component) — levels JSON in, one multi-page `.drawio` out with official C4 shapes/colors and **click-to-drill-down** links between levels |
diff --git a/skills/drawio-skill/scripts/drawio2pptx.py b/skills/drawio-skill/scripts/drawio2pptx.py
new file mode 100644
index 0000000..85b37f2
--- /dev/null
+++ b/skills/drawio-skill/scripts/drawio2pptx.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python3
+"""Turn a .drawio into a PowerPoint deck — one slide per page.
+
+Exports each page of a (multi-page) .drawio to a PNG via the draw.io CLI and
+lays them into a 16:9 .pptx, one page per slide, scaled to fit with the page
+name as the slide title. A C4 model (Context / Container / Component) becomes a
+ready-to-present deck; any multi-page diagram becomes a slide sequence.
+
+ python3 drawio2pptx.py c4.drawio -o c4.pptx
+ python3 drawio2pptx.py architecture.drawio # -> architecture.pptx
+
+Needs the draw.io CLI (for the PNG export) and the `python-pptx` package
+(`pip install python-pptx`) for writing the deck. Slides are 13.333in × 7.5in
+(16:9); each image is centred and scaled to fit inside a small margin.
+
+Usage: python3 drawio2pptx.py <file.drawio> [-o out.pptx] [--scale N]
+"""
+import argparse
+import os
+import struct
+import subprocess
+import sys
+import tempfile
+import xml.etree.ElementTree as ET
+
+
+def page_names(path):
+ """Names of the <diagram> pages, in order (None where unnamed)."""
+ try:
+ root = ET.parse(path).getroot()
+ except (ET.ParseError, OSError) as exc:
+ sys.exit(f"error: cannot parse {path}: {exc}")
+ diagrams = root.findall("diagram")
+ return [d.get("name") for d in diagrams] if diagrams else [None]
+
+
+def png_size(path):
+ """(width, height) in pixels from a PNG's IHDR header."""
+ with open(path, "rb") as f:
+ head = f.read(24)
+ return struct.unpack(">II", head[16:24])
+
+
+def export_page(drawio_file, index, out_png, scale):
+ """Export one page (1-based index) to PNG via the draw.io CLI."""
+ r = subprocess.run(["drawio", "-x", "-f", "png", "--page-index", str(index),
+ "-s", str(scale), "-o", out_png, drawio_file],
+ capture_output=True)
+ return r.returncode == 0 and os.path.exists(out_png)
+
+
+def main():
+ ap = argparse.ArgumentParser(description="Export a .drawio to a PowerPoint deck (one slide per page).")
+ ap.add_argument("file")
+ ap.add_argument("-o", "--output", help="output .pptx (default: alongside input)")
+ ap.add_argument("--scale", type=float, default=2.0, help="PNG export scale (default 2)")
+ args = ap.parse_args()
+
+ if not os.path.isfile(args.file):
+ sys.exit(f"error: {args.file} not found")
+ try:
+ from pptx import Presentation
+ from pptx.util import Emu, Pt
+ except ImportError:
+ sys.exit("error: python-pptx is required (pip install python-pptx)")
+
+ names = page_names(args.file)
+ out = args.output or os.path.splitext(args.file)[0] + ".pptx"
+
+ prs = Presentation()
+ prs.slide_width = Emu(12192000) # 13.333in — 16:9
+ prs.slide_height = Emu(6858000) # 7.5in
+ blank = prs.slide_layouts[6] # the built-in "Blank" layout
+ sw, sh = int(prs.slide_width), int(prs.slide_height)
+ margin = Emu(457200) # 0.5in
+ title_h = Emu(500000)
+
+ made = 0
+ with tempfile.TemporaryDirectory() as tmp:
+ for i, name in enumerate(names, 1): # draw.io --page-index is 1-based
+ png = os.path.join(tmp, f"page{i}.png")
+ if not export_page(args.file, i, png, args.scale):
+ sys.stderr.write(f"warning: page {i} export failed — skipped\n")
+ continue
+ slide = prs.slides.add_slide(blank)
+ top_pad = margin
+ if name:
+ box = slide.shapes.add_textbox(margin, Emu(180000),
+ Emu(sw - 2 * int(margin)), title_h)
+ tf = box.text_frame
+ tf.text = name
+ tf.paragraphs[0].runs[0].font.size = Pt(20)
+ tf.paragraphs[0].runs[0].font.bold = True
+ top_pad = Emu(180000) + title_h
+
+ cw, ch = sw - 2 * int(margin), sh - int(top_pad) - int(margin)
+ pw, ph = png_size(png)
+ scale = min(cw / pw, ch / ph) # fit, preserve aspect
+ iw, ih = int(pw * scale), int(ph * scale)
+ left = Emu(int((sw - iw) / 2))
+ top = Emu(int(top_pad) + int((ch - ih) / 2))
+ slide.shapes.add_picture(png, left, top, width=Emu(iw), height=Emu(ih))
+ made += 1
+
+ if not made:
+ sys.exit("error: no pages exported (is the draw.io CLI installed?)")
+ prs.save(out)
+ sys.stderr.write(f"wrote {out} ({made} slide{'s' if made != 1 else ''})\n")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/test_scripts.py b/tests/test_scripts.py
index a673a15..9b8641f 100644
--- a/tests/test_scripts.py
+++ b/tests/test_scripts.py
@@ -779,6 +779,50 @@ class TestImportersCli(unittest.TestCase):
self.assertIn("## Page 2: P2", md)
self.assertIn("- Solo", md)
+ def test_drawio2pptx_page_names(self):
+ tp = load("drawio2pptx")
+ doc = ('<mxfile>'
+ '<diagram name="Context"><mxGraphModel><root></root></mxGraphModel></diagram>'
+ '<diagram name="Containers"><mxGraphModel><root></root></mxGraphModel></diagram>'
+ '</mxfile>')
+ with tempfile.TemporaryDirectory() as d:
+ path = os.path.join(d, "c4.drawio")
+ self._write(path, doc)
+ self.assertEqual(tp.page_names(path), ["Context", "Containers"])
+
+ def test_drawio2pptx_png_size(self):
+ tp = load("drawio2pptx")
+ import struct
+ blob = b"\x00" * 16 + struct.pack(">II", 1280, 720) # IHDR w/h at [16:24]
+ with tempfile.TemporaryDirectory() as d:
+ path = os.path.join(d, "x.png")
+ with open(path, "wb") as f:
+ f.write(blob)
+ self.assertEqual(tp.png_size(path), (1280, 720))
+
+ def test_drawio2pptx_deck(self):
+ import shutil
+ try:
+ import pptx # noqa: F401
+ except ImportError:
+ self.skipTest("python-pptx not installed")
+ if not (shutil.which("drawio") and shutil.which("dot")):
+ self.skipTest("draw.io CLI / Graphviz not installed")
+ graph = {"direction": "TB",
+ "nodes": [{"id": "a", "label": "A"}, {"id": "b", "label": "B"}],
+ "edges": [{"source": "a", "target": "b"}]}
+ with tempfile.TemporaryDirectory() as d:
+ gj = os.path.join(d, "g.json")
+ self._write(gj, json.dumps(graph))
+ dr = os.path.join(d, "g.drawio")
+ self.assertEqual(run("autolayout.py", gj, "-o", dr).returncode, 0)
+ out = os.path.join(d, "g.pptx")
+ r = run("drawio2pptx.py", dr, "-o", out)
+ self.assertEqual(r.returncode, 0, r.stderr)
+ from pptx import Presentation
+ prs = Presentation(out)
+ self.assertEqual(len(prs.slides), 1)
+
SQL = ("CREATE TABLE users (id INT PRIMARY KEY, email VARCHAR(255));\n"
"CREATE TABLE orders (\n"
" id INT,\n"