Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

feat: support PPTX template sources in create-template workflow

hugohe3042c381692ae
diff --git a/README.md b/README.md
index 6c85cfcc..a6d4be4f 100644
--- a/README.md
+++ b/README.md
@@ -338,13 +338,15 @@ python3 skills/ppt-master/scripts/svg_to_pptx.py <project_path> -s final
Want to turn a PPT you love into a reusable template for PPT Master? Here's how:
-**Step 1 — Prepare Screenshots**
+**Step 1 — Prepare Reference Material**
-Take screenshots of the key page types from your reference PPT — cover page, table of contents, chapter divider, content page, and closing page. Save them as images in a single folder with clear, descriptive filenames (e.g., `cover.png`, `toc.png`, `chapter.png`, `content.png`, `closing.png`).
+The simplest path is still to prepare screenshots of the key page types from your reference PPT — cover page, table of contents, chapter divider, content page, and closing page. Save them as images in a single folder with clear, descriptive filenames (e.g., `cover.png`, `toc.png`, `chapter.png`, `content.png`, `closing.png`).
+
+If you already have the original `.pptx` template file, you can also provide it as a reference source. PPT Master can extract reusable background images, logos, theme colors, and font metadata from the PPTX first, then use those assets during template reconstruction. This is an internal preprocessing step — the visible `/create-template` workflow does not change.
**Step 2 — Let AI Create the Template**
-Use an AI coding agent (Claude Code, Codex, etc.) and ask it to use the **PPT Master `/create-template` workflow** to convert your screenshots into a template. In your prompt, provide:
+Use an AI coding agent (Claude Code, Codex, etc.) and ask it to use the **PPT Master `/create-template` workflow** to convert your reference material into a template. In your prompt, provide:
- The template's English name and Chinese name
- The intended use case (e.g., government reports, premium consulting, product launches)
diff --git a/README_CN.md b/README_CN.md
index ae872370..f3d772c8 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -334,13 +334,15 @@ python3 skills/ppt-master/scripts/svg_to_pptx.py <项目路径> -s final
想把自己喜欢的 PPT 模板制作成 PPT Master 可调用的模板?按以下步骤操作:
-**第一步 — 准备截图**
+**第一步 — 准备参考材料**
-将参考 PPT 的关键页面类型分别截图保存:欢迎页、目录页、章节页、内容页、结尾页。将截图放到同一个文件夹中,并使用规范的文件名(如 `cover.png`、`toc.png`、`chapter.png`、`content.png`、`closing.png`)。
+最简单的方式仍然是将参考 PPT 的关键页面类型分别截图保存:欢迎页、目录页、章节页、内容页、结尾页。将截图放到同一个文件夹中,并使用规范的文件名(如 `cover.png`、`toc.png`、`chapter.png`、`content.png`、`closing.png`)。
+
+如果你已经有原始 `.pptx` 模板文件,也可以把它作为参考源一并提供。PPT Master 会先从 PPTX 中提取可复用的背景图、logo、主题色和字体信息,再把这些素材用于模板重建。这个步骤是内部预处理,用户可见的 `/create-template` 工作流不变。
**第二步 — 让 AI 创建模板**
-使用 AI 编程代理(Claude Code、Codex 等),要求它使用 **PPT Master 的 `/create-template` 工作流**,将截图转换成模板。在提示中需要提供:
+使用 AI 编程代理(Claude Code、Codex 等),要求它使用 **PPT Master 的 `/create-template` 工作流**,将这些参考材料转换成模板。在提示中需要提供:
- 模板的英文名称和中文名称
- 适用场景(如政府汇报、高端咨询、产品宣讲等)
diff --git a/skills/ppt-master/references/template-designer.md b/skills/ppt-master/references/template-designer.md
index 256b7a9d..2a495d7a 100644
--- a/skills/ppt-master/references/template-designer.md
+++ b/skills/ppt-master/references/template-designer.md
@@ -14,6 +14,21 @@ Generate reusable page templates for the **global template library** based on a
- **Output location**: `templates/layouts/<template_name>/`
- **Input**: finalized template brief (template ID, display name, category, applicable scenarios, tone, theme mode, canvas format, optional reference assets)
+When the workflow provides PPTX import output, the effective input package becomes:
+
+- finalized template brief
+- `manifest.json`
+- `analysis.md`
+- exported `assets/`
+- optional screenshots for visual cross-checking
+
+Input priority for PPTX-backed template creation:
+
+1. `manifest.json` for factual metadata
+2. exported `assets/` for reusable visual resources
+3. `analysis.md` for page-type guidance
+4. screenshots / original PPTX only for style verification
+
---
## Core Template Inventory
@@ -67,6 +82,26 @@ Templates must strictly follow the finalized template brief and the generated `d
- **Font plan**: Uses font presets from the spec
- **Layout principles**: Margins and spacing conform to the spec
+If PPTX import output exists:
+- Prefer imported theme colors and fonts over visually guessed values
+- Reuse extracted backgrounds and logos where they are globally meaningful to the template
+- Treat page-type candidates from `analysis.md` as hints, not guarantees
+
+### 2.1 PPTX Import Simplification Rule
+
+The imported PPTX is a **reference source**, not a direct conversion target.
+
+Do:
+- preserve brand assets, recurring backgrounds, and stable structural motifs
+- rebuild the layout into a clean SVG structure aligned with PPT Master constraints
+- simplify repeated decorative fragments into a smaller number of maintainable SVG elements
+- use a background image asset when the original decorative layer is too complex to recreate cleanly
+
+Do not:
+- attempt 1:1 translation of every PowerPoint shape, group, shadow, or decorative fragment
+- mirror PPT-specific complexity when it makes the resulting SVG brittle or hard to edit
+- introduce dense low-value vector detail that does not materially improve template reuse
+
### 3. Placeholder Markers
Use clear placeholder markers for replaceable content:
@@ -115,6 +150,8 @@ For TOC pages in **newly created library templates**, use indexed placeholders:
Do **not** create new TOC placeholder families such as `{{CHAPTER_01_TITLE}}` for new templates. Existing templates may contain legacy placeholder variants, but new library assets should converge on the indexed TOC contract.
+When rebuilding from imported PPTX references, placeholder insertion takes priority over visual mimicry. If the original layout leaves insufficient room for canonical placeholders, adjust the layout instead of inventing one-off placeholder families.
+
---
## Output Requirements
@@ -136,6 +173,11 @@ templates/layouts/<template_name>/
After each template is generated, provide a brief summary table listing each template's status.
+If the template is based on PPTX import output, briefly note:
+- which extracted assets were reused directly
+- which complex original decorations were intentionally simplified
+- whether any page-type mapping required judgment beyond the import heuristic
+
---
## Using Pre-built Template Library (Optional)
diff --git a/skills/ppt-master/scripts/README.md b/skills/ppt-master/scripts/README.md
index ae8ef64e..ee4a241d 100644
--- a/skills/ppt-master/scripts/README.md
+++ b/skills/ppt-master/scripts/README.md
@@ -34,7 +34,7 @@ python3 scripts/update_repo.py
| Area | Primary scripts | Documentation |
|------|-----------------|---------------|
| Conversion | `pdf_to_md.py`, `doc_to_md.py`, `web_to_md.py`, `web_to_md.cjs` | [docs/conversion.md](./docs/conversion.md) |
-| Project management | `project_manager.py`, `batch_validate.py`, `generate_examples_index.py`, `error_helper.py` | [docs/project.md](./docs/project.md) |
+| Project management | `project_manager.py`, `batch_validate.py`, `generate_examples_index.py`, `error_helper.py`, `pptx_template_import.py` | [docs/project.md](./docs/project.md) |
| SVG pipeline | `finalize_svg.py`, `svg_to_pptx.py`, `total_md_split.py`, `svg_quality_checker.py` | [docs/svg-pipeline.md](./docs/svg-pipeline.md) |
| Image tools | `image_gen.py`, `analyze_images.py`, `gemini_watermark_remover.py` | [docs/image.md](./docs/image.md) |
| Repo maintenance | `update_repo.py` | README install/update section |
@@ -50,6 +50,12 @@ python3 scripts/project_manager.py import-sources <project_path> <source_files..
python3 scripts/project_manager.py validate <project_path>
```
+Template source import:
+
+```bash
+python3 scripts/pptx_template_import.py <template.pptx>
+```
+
Post-processing and export:
```bash
diff --git a/skills/ppt-master/scripts/docs/project.md b/skills/ppt-master/scripts/docs/project.md
index 06d82142..ea96d743 100644
--- a/skills/ppt-master/scripts/docs/project.md
+++ b/skills/ppt-master/scripts/docs/project.md
@@ -73,6 +73,22 @@ python3 scripts/generate_examples_index.py
python3 scripts/generate_examples_index.py examples
```
+## `pptx_template_import.py`
+
+Lightweight importer for `.pptx` template sources.
+
+```bash
+python3 scripts/pptx_template_import.py <template.pptx>
+python3 scripts/pptx_template_import.py <template.pptx> -o <output_dir>
+```
+
+Notes:
+- Extracts reusable media assets from `ppt/media/`
+- Summarizes slide size, theme colors, and font metadata
+- Infers background image inheritance across slide, layout, and master
+- Produces `manifest.json`, `analysis.md`, and `assets/`
+- Intended as an internal helper for template reconstruction, not a direct PPTX-to-SVG converter
+
## `error_helper.py`
Show standardized fixes for common project errors.
diff --git a/skills/ppt-master/scripts/pptx_template_import.py b/skills/ppt-master/scripts/pptx_template_import.py
new file mode 100644
index 00000000..aa0598c0
--- /dev/null
+++ b/skills/ppt-master/scripts/pptx_template_import.py
@@ -0,0 +1,508 @@
+#!/usr/bin/env python3
+"""Extract lightweight template assets and style metadata from a PPTX file.
+
+This helper is intentionally limited in scope:
+- extract reusable media assets
+- summarize slide size, theme colors, and fonts
+- infer common background assets through slide/layout/master inheritance
+- produce a compact manifest for downstream template reconstruction
+
+It does NOT try to convert arbitrary PPTX shapes into SVG templates.
+"""
+
+from __future__ import annotations
+
+import argparse
+import json
+import posixpath
+import re
+import shutil
+import zipfile
+from collections import Counter, defaultdict
+from dataclasses import dataclass
+from pathlib import Path, PurePosixPath
+from typing import Any
+from xml.etree import ElementTree as ET
+
+
+NS = {
+ "a": "http://schemas.openxmlformats.org/drawingml/2006/main",
+ "p": "http://schemas.openxmlformats.org/presentationml/2006/main",
+ "r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
+ "rel": "http://schemas.openxmlformats.org/package/2006/relationships",
+}
+
+EMU_PER_INCH = 914400
+
+SLIDE_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
+LAYOUT_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
+MASTER_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
+THEME_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
+IMAGE_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
+
+THANKS_KEYWORDS = ("thank", "thanks", "q&a", "qa", "contact", "致谢", "谢谢", "感谢", "答疑", "联系方式")
+TOC_KEYWORDS = ("agenda", "contents", "content", "outline", "目录", "议程", "目录页")
+CHAPTER_KEYWORDS = ("chapter", "part", "section", "章节", "部分")
+
+
+@dataclass
+class SlideRecord:
+ index: int
+ name: str
+ slide_path: str
+ layout_path: str | None
+ master_path: str | None
+ background_asset: str | None
+ background_source: str | None
+ image_assets: list[str]
+ text_samples: list[str]
+ text_count: int
+ shape_count: int
+ page_type: str
+
+
+def normalize_part(path: str, base: str | None = None) -> str:
+ if base:
+ path = str(PurePosixPath(base).parent.joinpath(path))
+ path = path.replace("\\", "/")
+ normalized = posixpath.normpath(path)
+ if normalized.startswith("./"):
+ normalized = normalized[2:]
+ return normalized.lstrip("/")
+
+
+def rels_path_for(part_path: str) -> str:
+ part = PurePosixPath(part_path)
+ return str(part.parent / "_rels" / f"{part.name}.rels")
+
+
+def load_xml_from_zip(zf: zipfile.ZipFile, part_path: str) -> ET.Element | None:
+ try:
+ with zf.open(part_path) as fh:
+ return ET.parse(fh).getroot()
+ except KeyError:
+ return None
+ except ET.ParseError:
+ return None
+
+
+def parse_relationships(zf: zipfile.ZipFile, part_path: str) -> dict[str, dict[str, str]]:
+ rels_root = load_xml_from_zip(zf, rels_path_for(part_path))
+ if rels_root is None:
+ return {}
+
+ rels: dict[str, dict[str, str]] = {}
+ for rel in rels_root.findall("rel:Relationship", NS):
+ rel_id = rel.attrib.get("Id")
+ target = rel.attrib.get("Target")
+ rel_type = rel.attrib.get("Type")
+ if not rel_id or not target or not rel_type:
+ continue
+ rels[rel_id] = {
+ "type": rel_type,
+ "target": normalize_part(target, part_path),
+ }
+ return rels
+
+
+def emu_to_pixels(value: int) -> int:
+ # PowerPoint uses 96 dpi; enough for summary output.
+ return int(round(value / EMU_PER_INCH * 96))
+
+
+def sanitize_filename(value: str) -> str:
+ value = re.sub(r"[^A-Za-z0-9._-]+", "_", value.strip())
+ return value.strip("._") or "asset"
+
+
+def extract_text_samples(root: ET.Element | None, limit: int = 6) -> list[str]:
+ if root is None:
+ return []
+ samples: list[str] = []
+ for node in root.findall(".//a:t", NS):
+ text = (node.text or "").strip()
+ if not text:
+ continue
+ samples.append(text)
+ if len(samples) >= limit:
+ break
+ return samples
+
+
+def extract_image_targets(root: ET.Element | None, rels: dict[str, dict[str, str]]) -> list[str]:
+ if root is None:
+ return []
+ targets: list[str] = []
+ seen: set[str] = set()
+ for blip in root.findall(".//a:blip", NS):
+ rel_id = blip.attrib.get(f"{{{NS['r']}}}embed")
+ if not rel_id:
+ continue
+ rel = rels.get(rel_id)
+ if not rel or rel["type"] != IMAGE_REL:
+ continue
+ target = rel["target"]
+ if target in seen:
+ continue
+ seen.add(target)
+ targets.append(target)
+ return targets
+
+
+def detect_background_asset(root: ET.Element | None, rels: dict[str, dict[str, str]]) -> str | None:
+ if root is None:
+ return None
+
+ bg = root.find("p:cSld/p:bg", NS)
+ if bg is None:
+ bg = root.find("p:bg", NS)
+ if bg is None:
+ return None
+
+ blip = bg.find(".//a:blip", NS)
+ if blip is None:
+ return None
+
+ rel_id = blip.attrib.get(f"{{{NS['r']}}}embed")
+ if not rel_id:
+ return None
+ rel = rels.get(rel_id)
+ if not rel or rel["type"] != IMAGE_REL:
+ return None
+ return rel["target"]
+
+
+def count_slide_shapes(root: ET.Element | None) -> int:
+ if root is None:
+ return 0
+ sp_tree = root.find("p:cSld/p:spTree", NS)
+ if sp_tree is None:
+ return 0
+ return len(list(sp_tree))
+
+
+def classify_slide(index: int, total: int, texts: list[str], image_count: int, shape_count: int) -> str:
+ joined = " ".join(texts).lower()
+ if any(keyword in joined for keyword in THANKS_KEYWORDS):
+ return "ending_candidate"
+ if any(keyword in joined for keyword in TOC_KEYWORDS):
+ return "toc_candidate"
+ if any(keyword in joined for keyword in CHAPTER_KEYWORDS):
+ return "chapter_candidate"
+ if index == 1 and image_count <= 3:
+ return "cover_candidate"
+ if index == total and len(texts) <= 6:
+ return "ending_candidate"
+ if len(texts) <= 3 and shape_count <= 12:
+ return "chapter_candidate"
+ return "content_candidate"
+
+
+def parse_theme(root: ET.Element | None) -> dict[str, Any]:
+ if root is None:
+ return {"colors": {}, "fonts": {}}
+
+ colors: dict[str, str] = {}
+ clr_scheme = root.find(".//a:clrScheme", NS)
+ if clr_scheme is not None:
+ for child in list(clr_scheme):
+ if not isinstance(child.tag, str):
+ continue
+ name = child.tag.split("}", 1)[-1]
+ srgb = child.find("a:srgbClr", NS)
+ sys_clr = child.find("a:sysClr", NS)
+ if srgb is not None and "val" in srgb.attrib:
+ colors[name] = f"#{srgb.attrib['val']}"
+ elif sys_clr is not None:
+ last = sys_clr.attrib.get("lastClr")
+ if last:
+ colors[name] = f"#{last}"
+
+ fonts: dict[str, str] = {}
+ font_scheme = root.find(".//a:fontScheme", NS)
+ if font_scheme is not None:
+ major = font_scheme.find("a:majorFont", NS)
+ minor = font_scheme.find("a:minorFont", NS)
+ if major is not None:
+ latin = major.find("a:latin", NS)
+ if latin is not None and latin.attrib.get("typeface"):
+ fonts["majorLatin"] = latin.attrib["typeface"]
+ if minor is not None:
+ latin = minor.find("a:latin", NS)
+ if latin is not None and latin.attrib.get("typeface"):
+ fonts["minorLatin"] = latin.attrib["typeface"]
+ ea = minor.find("a:ea", NS)
+ if ea is not None and ea.attrib.get("typeface"):
+ fonts["minorEastAsia"] = ea.attrib["typeface"]
+
+ return {"colors": colors, "fonts": fonts}
+
+
+def choose_common_assets(asset_usage: Counter[str]) -> list[str]:
+ common = [asset for asset, count in asset_usage.items() if count > 1]
+ return sorted(common)
+
+
+def write_analysis(
+ output_path: Path,
+ pptx_name: str,
+ slide_size: dict[str, int],
+ theme: dict[str, Any],
+ slides: list[SlideRecord],
+ common_assets: list[str],
+) -> None:
+ lines = [
+ f"# Template Import Analysis - {pptx_name}",
+ "",
+ "## Summary",
+ f"- Slide size: {slide_size['width_px']} x {slide_size['height_px']} px",
+ f"- Theme colors: {', '.join(sorted(theme['colors'].keys())) or 'none detected'}",
+ f"- Theme fonts: {', '.join(f'{k}={v}' for k, v in theme['fonts'].items()) or 'none detected'}",
+ f"- Common assets: {len(common_assets)}",
+ "",
+ "## Slide Candidates",
+ ]
+
+ for slide in slides:
+ sample = " | ".join(slide.text_samples[:3]) if slide.text_samples else "(no text sample)"
+ lines.extend(
+ [
+ f"- Slide {slide.index}: {slide.page_type}",
+ f" - Name: {slide.name}",
+ f" - Background: {slide.background_asset or 'none'} ({slide.background_source or 'n/a'})",
+ f" - Images: {len(slide.image_assets)}",
+ f" - Text sample: {sample}",
+ ]
+ )
+
+ output_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
+
+
+def build_manifest(pptx_path: Path, output_dir: Path) -> dict[str, Any]:
+ with zipfile.ZipFile(pptx_path, "r") as zf:
+ presentation_root = load_xml_from_zip(zf, "ppt/presentation.xml")
+ if presentation_root is None:
+ raise RuntimeError("Invalid PPTX: missing ppt/presentation.xml")
+
+ slide_size = {"width_emu": 0, "height_emu": 0, "width_px": 0, "height_px": 0}
+ sld_sz = presentation_root.find("p:sldSz", NS)
+ if sld_sz is not None:
+ width_emu = int(sld_sz.attrib.get("cx", "0"))
+ height_emu = int(sld_sz.attrib.get("cy", "0"))
+ slide_size = {
+ "width_emu": width_emu,
+ "height_emu": height_emu,
+ "width_px": emu_to_pixels(width_emu),
+ "height_px": emu_to_pixels(height_emu),
+ }
+
+ presentation_rels = parse_relationships(zf, "ppt/presentation.xml")
+ slide_parts: list[str] = []
+ for sld_id in presentation_root.findall("p:sldIdLst/p:sldId", NS):
+ rel_id = sld_id.attrib.get(f"{{{NS['r']}}}id")
+ rel = presentation_rels.get(rel_id or "")
+ if rel and rel["type"] == SLIDE_REL:
+ slide_parts.append(rel["target"])
+
+ asset_dir = output_dir / "assets"
+ asset_dir.mkdir(parents=True, exist_ok=True)
+
+ copied_assets: dict[str, str] = {}
+ for info in zf.infolist():
+ if not info.filename.startswith("ppt/media/") or info.is_dir():
+ continue
+ original_name = PurePosixPath(info.filename).name
+ safe_name = sanitize_filename(original_name)
+ destination = asset_dir / safe_name
+ stem = destination.stem
+ suffix = destination.suffix
+ counter = 2
+ while destination.exists():
+ destination = asset_dir / f"{stem}_{counter}{suffix}"
+ counter += 1
+ with zf.open(info.filename) as src, open(destination, "wb") as dst:
+ shutil.copyfileobj(src, dst)
+ copied_assets[info.filename] = destination.name
+
+ slide_records: list[SlideRecord] = []
+ asset_usage: Counter[str] = Counter()
+
+ theme_summary = {"colors": {}, "fonts": {}}
+
+ for index, slide_path in enumerate(slide_parts, 1):
+ slide_root = load_xml_from_zip(zf, slide_path)
+ slide_rels = parse_relationships(zf, slide_path)
+
+ layout_path = None
+ for rel in slide_rels.values():
+ if rel["type"] == LAYOUT_REL:
+ layout_path = rel["target"]
+ break
+
+ layout_root = load_xml_from_zip(zf, layout_path) if layout_path else None
+ layout_rels = parse_relationships(zf, layout_path) if layout_path else {}
+
+ master_path = None
+ for rel in layout_rels.values():
+ if rel["type"] == MASTER_REL:
+ master_path = rel["target"]
+ break
+
+ master_root = load_xml_from_zip(zf, master_path) if master_path else None
+ master_rels = parse_relationships(zf, master_path) if master_path else {}
+
+ theme_path = None
+ for rel in master_rels.values():
+ if rel["type"] == THEME_REL:
+ theme_path = rel["target"]
+ break
+ if theme_path and not theme_summary["colors"] and not theme_summary["fonts"]:
+ theme_summary = parse_theme(load_xml_from_zip(zf, theme_path))
+
+ bg_asset = None
+ bg_source = None
+ for label, root, rels in (
+ ("slide", slide_root, slide_rels),
+ ("layout", layout_root, layout_rels),
+ ("master", master_root, master_rels),
+ ):
+ candidate = detect_background_asset(root, rels)
+ if candidate:
+ bg_asset = candidate
+ bg_source = label
+ break
+
+ image_targets = extract_image_targets(slide_root, slide_rels)
+ texts = extract_text_samples(slide_root)
+ shape_count = count_slide_shapes(slide_root)
+ page_type = classify_slide(index, len(slide_parts), texts, len(image_targets), shape_count)
+
+ resolved_bg = copied_assets.get(bg_asset, PurePosixPath(bg_asset).name if bg_asset else None)
+ resolved_images = [
+ copied_assets.get(target, PurePosixPath(target).name)
+ for target in image_targets
+ ]
+
+ if resolved_bg:
+ asset_usage[resolved_bg] += 1
+ for asset_name in resolved_images:
+ asset_usage[asset_name] += 1
+
+ slide_records.append(
+ SlideRecord(
+ index=index,
+ name=PurePosixPath(slide_path).name,
+ slide_path=slide_path,
+ layout_path=layout_path,
+ master_path=master_path,
+ background_asset=resolved_bg,
+ background_source=bg_source,
+ image_assets=resolved_images,
+ text_samples=texts,
+ text_count=len(texts),
+ shape_count=shape_count,
+ page_type=page_type,
+ )
+ )
+
+ common_assets = choose_common_assets(asset_usage)
+ page_type_map: dict[str, list[int]] = defaultdict(list)
+ for slide in slide_records:
+ page_type_map[slide.page_type].append(slide.index)
+
+ manifest = {
+ "source": {
+ "pptx": str(pptx_path),
+ "name": pptx_path.name,
+ },
+ "slideSize": slide_size,
+ "theme": theme_summary,
+ "assets": {
+ "exportDir": "assets",
+ "commonAssets": common_assets,
+ "allAssets": sorted(copied_assets.values()),
+ },
+ "pageTypeCandidates": dict(sorted(page_type_map.items())),
+ "slides": [
+ {
+ "index": slide.index,
+ "name": slide.name,
+ "slidePath": slide.slide_path,
+ "layoutPath": slide.layout_path,
+ "masterPath": slide.master_path,
+ "backgroundAsset": slide.background_asset,
+ "backgroundSource": slide.background_source,
+ "imageAssets": slide.image_assets,
+ "textSamples": slide.text_samples,
+ "textCount": slide.text_count,
+ "shapeCount": slide.shape_count,
+ "pageType": slide.page_type,
+ }
+ for slide in slide_records
+ ],
+ }
+
+ write_analysis(
+ output_dir / "analysis.md",
+ pptx_path.name,
+ slide_size,
+ theme_summary,
+ slide_records,
+ common_assets,
+ )
+ return manifest
+
+
+def parse_args() -> argparse.Namespace:
+ parser = argparse.ArgumentParser(
+ description="Extract reusable assets and style metadata from a PPTX template source."
+ )
+ parser.add_argument("pptx_file", help="Path to the source .pptx file")
+ parser.add_argument(
+ "-o",
+ "--output",
+ help="Output directory (default: <pptx_stem>_template_import beside the source file)",
+ )
+ return parser.parse_args()
+
+
+def main() -> int:
+ args = parse_args()
+ pptx_path = Path(args.pptx_file).expanduser().resolve()
+ if not pptx_path.exists():
+ print(f"Error: file does not exist: {pptx_path}")
+ return 1
+ if pptx_path.suffix.lower() != ".pptx":
+ print(f"Error: expected a .pptx file, got: {pptx_path.name}")
+ return 1
+
+ output_dir = (
+ Path(args.output).expanduser().resolve()
+ if args.output
+ else pptx_path.with_name(f"{pptx_path.stem}_template_import")
+ )
+ output_dir.mkdir(parents=True, exist_ok=True)
+
+ try:
+ manifest = build_manifest(pptx_path, output_dir)
+ except Exception as exc:
+ print(f"Error: failed to import template source: {exc}")
+ return 1
+
+ manifest_path = output_dir / "manifest.json"
+ manifest_path.write_text(
+ json.dumps(manifest, ensure_ascii=False, indent=2) + "\n",
+ encoding="utf-8",
+ )
+
+ print(f"Imported PPTX template source: {pptx_path.name}")
+ print(f"Output directory: {output_dir}")
+ print(f"Manifest: {manifest_path.name}")
+ print(f"Assets exported: {len(manifest['assets']['allAssets'])}")
+ print(f"Common assets: {len(manifest['assets']['commonAssets'])}")
+ print(f"Slides analyzed: {len(manifest['slides'])}")
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/skills/ppt-master/workflows/create-template.md b/skills/ppt-master/workflows/create-template.md
index d753d417..354a507d 100644
--- a/skills/ppt-master/workflows/create-template.md
+++ b/skills/ppt-master/workflows/create-template.md
@@ -31,7 +31,7 @@ Confirm the following with the user:
| Tone summary | Yes | Short tone description for recommendation, such as `Modern, restrained, data-driven` |
| Theme mode | Yes | Theme description for recommendation, such as `Light theme (white background + blue accent)` |
| Canvas format | Yes | Default `ppt169`; if another format is needed, specify it explicitly before generation |
-| Reference source | Optional | Existing project or template path |
+| Reference source | Optional | Existing project, screenshot folder, or `.pptx` template file path |
| Theme color | Optional | Primary color HEX value (can be auto-extracted from reference) |
| Design style | Optional | Additional style notes, decorative language, brand cues |
| Assets list | Optional | Logos / background textures / reference images to include in the template package |
@@ -49,6 +49,30 @@ Confirm the following with the user:
ls -la "<reference_source_path>"
```
+If the reference source is a `.pptx` template file, first run the lightweight import helper to extract reusable assets and style metadata:
+
+```bash
+python3 skills/ppt-master/scripts/pptx_template_import.py "<reference_template.pptx>"
+```
+
+Use the generated `manifest.json`, `analysis.md`, and exported `assets/` as internal reference material for template reconstruction. This helper is intentionally limited to asset/style extraction; it does **not** directly convert the PPTX into final template SVG files.
+
+When `.pptx` import output exists, use the following internal priority order during template creation:
+
+1. `manifest.json`
+2. `analysis.md`
+3. exported `assets/`
+4. user-provided screenshots or the original PPTX only for visual cross-checking
+
+Interpretation rule:
+
+- `manifest.json` is the source of truth for slide size, theme colors, fonts, background inheritance, and reusable asset inventory
+- `analysis.md` is the compact human-readable summary used to guide page-type selection
+- exported `assets/` are the preferred source for backgrounds, logos, and decorative images
+- screenshots remain useful for judging composition and style, but should not override extracted factual metadata unless the import result is clearly incomplete
+
+Do **not** treat the imported PPTX as a direct SVG conversion target. The goal is to reconstruct a clean, maintainable PPT Master template package, not to perform 1:1 shape translation.
+
---
## Step 2: Create Template Directory
@@ -67,6 +91,16 @@ mkdir -p "skills/ppt-master/templates/layouts/<template_id>"
**Switch to the Template_Designer role** and generate per role definition. The role input is the finalized template brief from Step 1, not a project design spec.
+If `.pptx` import output exists, pass the following internal package to the role:
+
+- finalized template brief from Step 1
+- `manifest.json`
+- `analysis.md`
+- exported `assets/`
+- optional screenshots, if available
+
+The role should use the import output to anchor objective facts such as theme colors, fonts, reusable backgrounds, and common branding assets, then rebuild the final SVG templates in a simplified, maintainable form.
+
1. **design_spec.md** — Design specification document
2. **4 core templates** — Cover, chapter, content, ending pages
3. **TOC page (optional)** — `02_toc.svg`