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

fix(image-gen): dotted manifest filenames no longer overwrite each other

hugohe3e9676c5a8bd6
diff --git a/skills/ppt-master/scripts/image_gen.py b/skills/ppt-master/scripts/image_gen.py
index dece33e9..6f95e39c 100644
--- a/skills/ppt-master/scripts/image_gen.py
+++ b/skills/ppt-master/scripts/image_gen.py
@@ -998,7 +998,7 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
aspect_ratio=item["aspect_ratio"],
image_size=item.get("image_size", image_size),
output_dir=output_dir,
- filename=Path(item["filename"]).stem,
+ filename=item["filename"], # the backend strips the extension once
model=item.get("model", model),
)
saved_path = _materialize_manifest_image(
diff --git a/skills/ppt-master/scripts/tests/test_image_gen_manifest.py b/skills/ppt-master/scripts/tests/test_image_gen_manifest.py
new file mode 100644
index 00000000..58454d9b
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_image_gen_manifest.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+"""Regression tests for manifest-driven image generation output names."""
+
+from __future__ import annotations
+
+import contextlib
+import io
+import json
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from types import SimpleNamespace
+
+SCRIPTS_DIR = Path(__file__).resolve().parents[1]
+if str(SCRIPTS_DIR) not in sys.path:
+ sys.path.insert(0, str(SCRIPTS_DIR))
+
+import image_gen # noqa: E402
+from image_backends import backend_common # noqa: E402
+
+
+class ManifestOutputNameTests(unittest.TestCase):
+ def test_dotted_filenames_do_not_overwrite_each_other(self) -> None:
+ from PIL import Image
+
+ def generate(**kwargs: object) -> str:
+ path = backend_common.resolve_output_path(
+ str(kwargs["prompt"]), str(kwargs["output_dir"]), str(kwargs["filename"])
+ )
+ Image.new("RGB", (8, 8), str(kwargs["prompt"])).save(path, format="PNG")
+ return path
+
+ with tempfile.TemporaryDirectory() as tmp:
+ manifest_path = Path(tmp) / "image_prompts.json"
+ items = [
+ {"filename": name, "prompt": color, "aspect_ratio": "1:1", "status": "Pending",
+ "page_role": "local", "text_policy": "none"}
+ for name, color in (("hero.png", "red"), ("hero.v2.png", "blue"))
+ ]
+ manifest_path.write_text(json.dumps({"items": items}), encoding="utf-8")
+ manifest = image_gen.load_manifest(str(manifest_path))
+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
+ image_gen._run_manifest(
+ manifest, str(manifest_path), SimpleNamespace(generate=generate),
+ initial_concurrency=1, image_size="1K", output_dir=tmp, model=None,
+ )
+ with Image.open(Path(tmp) / "hero.png") as first, \
+ Image.open(Path(tmp) / "hero.v2.png") as second:
+ self.assertEqual(first.getpixel((0, 0)), (255, 0, 0))
+ self.assertEqual(second.getpixel((0, 0)), (0, 0, 255))
+