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(project_manager): propagate source image assets into project images/ with namespacing

hugohe3623aca903093
diff --git a/skills/ppt-master/SKILL.md b/skills/ppt-master/SKILL.md
index 0e5af519..83882262 100644
--- a/skills/ppt-master/SKILL.md
+++ b/skills/ppt-master/SKILL.md
@@ -104,6 +104,20 @@ When the user provides non-Markdown content, convert immediately:
| WeChat / high-security site | `python3 ${SKILL_DIR}/scripts/source_to_md/web_to_md.py <URL>` (requires `curl_cffi`, included in `requirements.txt`) |
| Markdown | Read directly |
+> **Office vector assets (EMF/WMF) from DOCX/PPTX sources**:
+> `doc_to_md.py` / `ppt_to_md.py` extract embedded Office vector images (.emf/.wmf)
+> alongside bitmap images. After `import-sources`, these land in `images/`
+> together with `image_manifest.json` and are first-class assets in §VIII Image Resource List.
+>
+> **Do NOT convert EMF/WMF to PNG.** The PPT Master pipeline preserves them as external
+> references (`finalize_svg.py` skips them) and `svg_to_pptx.py` embeds them as
+> PPTX-native media via `image/x-emf` / `image/x-wmf` MIME — PowerPoint renders them at full vector fidelity.
+> Converting via LibreOffice/Inkscape introduces CJK font substitution drift and
+> rasterization loss; the original EMF/WMF is always higher fidelity than the converted PNG.
+>
+> Browser-based live preview cannot render EMF (will show blank) — this is expected;
+> the PPTX output is the source of truth.
+
**✅ Checkpoint — Confirm source content is ready, proceed to Step 2.**
---
diff --git a/skills/ppt-master/scripts/analyze_images.py b/skills/ppt-master/scripts/analyze_images.py
index 83b0f837..548a9c6f 100644
--- a/skills/ppt-master/scripts/analyze_images.py
+++ b/skills/ppt-master/scripts/analyze_images.py
@@ -51,6 +51,7 @@ except ImportError:
}
IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".tiff", ".tif"}
+OFFICE_VECTOR_EXTENSIONS = {".emf", ".wmf"}
REPORT_WIDTH = 100
CATEGORY_WIDTH = 50
@@ -87,6 +88,32 @@ def _load_image_manifest(images_dir: str) -> dict[str, dict]:
return manifest
+def _warn_office_vectors_without_manifest(images_dir: str, manifest: dict[str, dict]) -> None:
+ """Warn when EMF/WMF files cannot be reported because manifest metadata is absent."""
+ if manifest:
+ return
+
+ vector_files = [
+ path for path in Path(images_dir).iterdir()
+ if path.is_file() and path.suffix.lower() in OFFICE_VECTOR_EXTENSIONS
+ ]
+ if not vector_files:
+ return
+
+ print(
+ f"[WARN] Found {len(vector_files)} office vector file(s) (.emf/.wmf) "
+ "but no image_manifest.json found."
+ )
+ print(
+ " Dimensions and metadata unknown — these assets will NOT appear "
+ "in the analysis report."
+ )
+ print(
+ " To fix: ensure image_manifest.json is present in images/ "
+ "(auto-generated by doc_to_md.py for DOCX sources)."
+ )
+
+
def _manifest_ratio(meta: dict | None) -> float | None:
"""Return a positive display ratio from manifest metadata."""
if not meta:
@@ -338,6 +365,7 @@ def analyze_images(images_dir: str) -> list[ImageAnalysis]:
if result:
results.append(result)
+ _warn_office_vectors_without_manifest(images_dir, manifest)
return results
diff --git a/skills/ppt-master/scripts/project_manager.py b/skills/ppt-master/scripts/project_manager.py
index 4e7d0b60..8e3d2d59 100644
--- a/skills/ppt-master/scripts/project_manager.py
+++ b/skills/ppt-master/scripts/project_manager.py
@@ -10,6 +10,7 @@ Usage:
from __future__ import annotations
+import json
import re
import shutil
import subprocess
@@ -56,6 +57,10 @@ DOC_SUFFIXES = {
".ipynb", ".typ", # Notebooks / Typst
}
WECHAT_HOST_KEYWORDS = ("mp.weixin.qq.com", "weixin.qq.com")
+IMAGE_ASSET_SUFFIXES = {
+ ".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".tiff", ".tif",
+ ".emf", ".wmf", ".svg",
+}
def _curl_cffi_available() -> bool:
@@ -359,6 +364,118 @@ class ProjectManager:
if updated != content:
markdown_path.write_text(updated, encoding="utf-8")
+ def _merge_image_manifest(self, source_items: list[dict], destination_manifest: Path) -> None:
+ """Merge per-source manifest items into the project-level manifest, keyed by filename."""
+ existing_data: list[object] = []
+ if destination_manifest.is_file():
+ try:
+ loaded = json.loads(destination_manifest.read_text(encoding="utf-8"))
+ if isinstance(loaded, list):
+ existing_data = loaded
+ else:
+ print(f"[WARN] Replacing non-list image manifest: {destination_manifest}")
+ except (OSError, json.JSONDecodeError) as exc:
+ print(f"[WARN] Replacing unreadable image manifest {destination_manifest}: {exc}")
+
+ new_by_filename: dict[str, dict] = {}
+ new_order: list[str] = []
+ for item in source_items:
+ filename = item.get("filename")
+ if not isinstance(filename, str):
+ continue
+ if filename not in new_by_filename:
+ new_order.append(filename)
+ new_by_filename[filename] = item
+
+ merged: list[dict] = []
+ seen: set[str] = set()
+ for item in existing_data:
+ if not isinstance(item, dict):
+ continue
+ filename = item.get("filename")
+ if not isinstance(filename, str):
+ continue
+ if filename in new_by_filename:
+ merged.append(new_by_filename[filename])
+ else:
+ merged.append(item)
+ seen.add(filename)
+
+ for filename in new_order:
+ if filename not in seen:
+ merged.append(new_by_filename[filename])
+
+ destination_manifest.write_text(
+ json.dumps(merged, ensure_ascii=False, indent=2) + "\n",
+ encoding="utf-8",
+ )
+
+ @staticmethod
+ def _namespace_from_asset_dir(asset_dir: Path) -> str:
+ """Derive a per-source namespace from a `<stem>_files` companion directory name."""
+ name = asset_dir.name
+ suffix = "_files"
+ return name[:-len(suffix)] if name.endswith(suffix) else name
+
+ def _propagate_image_assets(self, asset_dir: Path, project_dir: Path) -> None:
+ """Copy converter-generated image assets and manifest into project images/.
+
+ Files are namespaced by source stem to avoid collisions when multiple
+ DOCX/PPTX sources contain identically-named internal media (image1.png, ...).
+ """
+ manifest_path = asset_dir / "image_manifest.json"
+ if not manifest_path.is_file():
+ return
+
+ try:
+ source_data = json.loads(manifest_path.read_text(encoding="utf-8"))
+ except (OSError, json.JSONDecodeError) as exc:
+ print(f"[WARN] Cannot read image manifest {manifest_path}: {exc}")
+ return
+ if not isinstance(source_data, list):
+ print(f"[WARN] Ignoring non-list image manifest: {manifest_path}")
+ return
+
+ images_dir = project_dir / "images"
+ images_dir.mkdir(parents=True, exist_ok=True)
+
+ namespace = self._namespace_from_asset_dir(asset_dir)
+ rename_map: dict[str, str] = {}
+
+ copied_count = 0
+ for source_file in sorted(asset_dir.iterdir()):
+ if not source_file.is_file():
+ continue
+ if source_file.suffix.lower() not in IMAGE_ASSET_SUFFIXES:
+ continue
+ new_name = f"{namespace}__{source_file.name}"
+ shutil.copy2(source_file, images_dir / new_name)
+ rename_map[source_file.name] = new_name
+ copied_count += 1
+
+ rebased_items: list[dict] = []
+ for item in source_data:
+ if not isinstance(item, dict):
+ continue
+ original = item.get("filename")
+ if not isinstance(original, str):
+ continue
+ new_item = dict(item)
+ new_item["filename"] = rename_map.get(original, f"{namespace}__{original}")
+ new_item["source_namespace"] = namespace
+ rebased_items.append(new_item)
+
+ self._merge_image_manifest(rebased_items, images_dir / "image_manifest.json")
+ print(
+ f"Propagated {copied_count} image asset(s) + manifest "
+ f"from {asset_dir} → images/ (namespace: {namespace})"
+ )
+
+ def _propagate_companion_image_assets(self, markdown_path: Path, project_dir: Path) -> None:
+ asset_dir = markdown_path.with_name(f"{markdown_path.stem}_files")
+ if asset_dir.is_dir():
+ self._propagate_image_assets(asset_dir, project_dir)
+
def _import_markdown_with_assets(
self,
source_path: Path,
@@ -440,6 +557,7 @@ class ProjectManager:
summary["archived"].append(str(archived))
summary["markdown"].append(str(markdown_path))
+ self._propagate_companion_image_assets(markdown_path, project_dir)
continue
source_path = Path(item)
@@ -469,6 +587,7 @@ class ProjectManager:
duplicate_markdown = self._find_equivalent_markdown(source_path, sources_dir)
if duplicate_markdown is not None:
summary["markdown"].append(str(duplicate_markdown))
+ self._propagate_companion_image_assets(duplicate_markdown, project_dir)
summary["notes"].append(
f"{item}: skipped duplicate markdown import because equivalent content already exists as {duplicate_markdown.name}"
)
@@ -483,6 +602,7 @@ class ProjectManager:
summary["markdown"].append(str(archived_markdown))
if asset_dir is not None:
summary["assets"].append(str(asset_dir))
+ self._propagate_image_assets(asset_dir, project_dir)
if note:
summary["notes"].append(note)
continue
@@ -503,6 +623,7 @@ class ProjectManager:
continue
if canonical_markdown_path.exists():
summary["markdown"].append(str(canonical_markdown_path))
+ self._propagate_companion_image_assets(canonical_markdown_path, project_dir)
summary["notes"].append(
f"{item}: skipped PDF auto-conversion because {canonical_markdown_path.name} already exists"
)
@@ -511,6 +632,7 @@ class ProjectManager:
try:
self._import_pdf(archived_path, markdown_path)
summary["markdown"].append(str(markdown_path))
+ self._propagate_companion_image_assets(markdown_path, project_dir)
except Exception as exc: # pragma: no cover - summary path
summary["skipped"].append(f"{item}: PDF conversion failed ({exc})")
elif suffix in PRESENTATION_SUFFIXES:
@@ -522,6 +644,7 @@ class ProjectManager:
continue
if canonical_markdown_path.exists():
summary["markdown"].append(str(canonical_markdown_path))
+ self._propagate_companion_image_assets(canonical_markdown_path, project_dir)
summary["notes"].append(
f"{item}: skipped presentation auto-conversion because {canonical_markdown_path.name} already exists"
)
@@ -530,6 +653,7 @@ class ProjectManager:
try:
self._import_presentation(archived_path, markdown_path)
summary["markdown"].append(str(markdown_path))
+ self._propagate_companion_image_assets(markdown_path, project_dir)
except Exception as exc: # pragma: no cover - summary path
summary["skipped"].append(f"{item}: presentation conversion failed ({exc})")
elif suffix in EXCEL_SUFFIXES:
@@ -541,6 +665,7 @@ class ProjectManager:
continue
if canonical_markdown_path.exists():
summary["markdown"].append(str(canonical_markdown_path))
+ self._propagate_companion_image_assets(canonical_markdown_path, project_dir)
summary["notes"].append(
f"{item}: skipped Excel auto-conversion because {canonical_markdown_path.name} already exists"
)
@@ -549,6 +674,7 @@ class ProjectManager:
try:
self._import_excel(archived_path, markdown_path)
summary["markdown"].append(str(markdown_path))
+ self._propagate_companion_image_assets(markdown_path, project_dir)
except Exception as exc: # pragma: no cover - summary path
summary["skipped"].append(f"{item}: Excel conversion failed ({exc})")
elif suffix in LEGACY_EXCEL_SUFFIXES:
@@ -569,6 +695,7 @@ class ProjectManager:
continue
if canonical_markdown_path.exists():
summary["markdown"].append(str(canonical_markdown_path))
+ self._propagate_companion_image_assets(canonical_markdown_path, project_dir)
summary["notes"].append(
f"{item}: skipped document auto-conversion because {canonical_markdown_path.name} already exists"
)
@@ -577,6 +704,7 @@ class ProjectManager:
try:
self._import_doc(archived_path, markdown_path)
summary["markdown"].append(str(markdown_path))
+ self._propagate_companion_image_assets(markdown_path, project_dir)
except Exception as exc: # pragma: no cover - summary path
summary["skipped"].append(f"{item}: document conversion failed ({exc})")
elif suffix == ".txt":