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(scripts): camera MPO JPEGs keep their primary frame across search, treat, and export
hugohe317d3109e5031
diff --git a/skills/ppt-master/scripts/docs/image.md b/skills/ppt-master/scripts/docs/image.mdindex 3a06d710..0d6adbb0 100644--- a/skills/ppt-master/scripts/docs/image.md+++ b/skills/ppt-master/scripts/docs/image.md@@ -180,7 +180,8 @@ duotone, Gaussian blur, and `--fit WxH` (downscale to fit inside a pixelbox, aspect ratio and alpha preserved; never upscales). They compose in afixed order: brightness → contrast → tone treatment → blur → fit. Desaturation, grayscale, and duotone aremutually exclusive. At least one option must produce a real change; animated-or multi-frame sources are rejected rather than reduced to one frame.+sources are rejected rather than reduced to one frame, while a camera+multi-picture JPEG (MPO) contributes its primary frame.Both input and output are bare filenames directly under `images/`; output mustbe a new `.png` file. The tool keeps the EXIF-corrected display dimensions,@@ -279,11 +280,11 @@ python3 scripts/image_search.py "abstract gradient" \Suitability & manual replacement (a web top hit is metadata-relevant, not guaranteed visually right):-- By default only the best match is downloaded, plus a downscaled review copy at `images/.review/<stem>.jpg` (the placed asset stays full-resolution).+- By default only the best match is downloaded, plus a downscaled review copy at `images/.review/<stem>.jpg` (the placed asset stays full-resolution). A downloaded camera multi-picture JPEG (MPO, common among Commons originals) is rewritten as its primary frame before validation so every later consumer sees a single-frame JPEG.- For exact subjects (landmarks, people, companies, products), use `--require-terms` or batch `required_terms` so visually plausible but wrong metadata is rejected before ranking. Example: `--require-terms Chongqing --require-terms "Jiefangbei|Liberation Monument"`. Keep proper-name / geography anchors; do not broaden to generic terms like `canyon`, `stone pillar`, or `ancient town` just to improve coverage.- When the current Generate agent can inspect images, use `--save-candidates`. The tool saves only the first ranked page of review-eligible provider previews (**8 by default**), writes `candidates/<stem>/review_sheet.jpg`, and leaves the target image and `image_sources.json` untouched. Standalone CLI use remains best-only unless this flag is explicit.- Compare the thumbnail set against the active Reference/Crop Policy. Only after one passes, run `--promote candidate_03.jpg --filename <name>.jpg`; this downloads and validates exactly that original. In batch mode, pass the same `--batch images/image_queries.json` so `Needs-Selection` becomes `Sourced`.-- If no thumbnail passes and `has_more_candidates` is true, fetch `--candidate-page 2` (or set the batch row's `candidate_page` to `next_candidate_page` and reset it to `Pending`). Candidate numbering continues at 9; no original is downloaded. Only after the pool is exhausted should you materially change the identity wording, viewpoint, translation, alias, or disambiguator and generate a fresh pool.+- If no thumbnail passes and `has_more_candidates` is true, fetch `--candidate-page 2` with the same query and filename — the pool's saved `required_terms`, `query_variants`, orientation, and minimum dimensions are inherited unless given again, and a changed query is refused as a page continuation (start a new page-1 pool instead). In batch mode pass `--candidate-page 2` to rerun every `Needs-Selection` row at that page, or set one row's `candidate_page` to `next_candidate_page` and reset only it to `Pending`. Candidate numbering continues at 9, earlier pages stay in `candidates.json` (`saved_pages`) so any saved thumbnail remains promotable, and no original is downloaded. Only after the pool is exhausted should you materially change the identity wording, viewpoint, translation, alias, or disambiguator and generate a fresh pool.- Without multimodal inspection, omit `--save-candidates`. Best-only mode rejects visual-verification-required near matches, accepts only a strict metadata candidate, downloads one original, and records `selection_method: metadata-ranked`; if metadata cannot prove the entity or the active visual requirement, use `Needs-Manual` rather than claiming visual confirmation.- `--from-url <url> --filename <name>.jpg` downloads a user-chosen image URL and replaces the target (recorded `license_tier: manual`) — the model-agnostic manual path; works even without a multimodal model.diff --git a/skills/ppt-master/scripts/image_search.py b/skills/ppt-master/scripts/image_search.pyindex fcce0ec5..a7d4aec7 100644--- a/skills/ppt-master/scripts/image_search.py+++ b/skills/ppt-master/scripts/image_search.py@@ -434,6 +434,59 @@ def _validate_downloaded_quality(return False+def _normalize_multi_frame_jpeg(path: Path) -> bool:+ """Rewrite a camera MPO (multi-picture JPEG) as its primary frame in place.++ Photo hosts serve stereo/multi-frame camera originals under a ``.jpg``+ extension. ``image_treat.py``, the quality checker, and the PPTX exporter+ all expect a single-frame JPEG, so the primary frame is re-encoded at high+ quality with its EXIF and ICC data and the sibling frames are dropped.+ Returns ``True`` when the file was rewritten.+ """+ if path.suffix.lower() not in {".jpg", ".jpeg"}:+ return False+ try:+ from PIL import Image # type: ignore+ except ImportError:+ return False+ try:+ with Image.open(path) as source:+ multi_frame = (+ (source.format or "").upper() == "MPO"+ or int(getattr(source, "n_frames", 1)) != 1+ )+ if not multi_frame:+ return False+ source.seek(0)+ frame = source.convert("RGB")+ save_kwargs: dict[str, object] = {"quality": 95}+ for key in ("exif", "icc_profile"):+ value = source.info.get(key)+ if value:+ save_kwargs[key] = value+ except (OSError, ValueError, SyntaxError):+ return False+ fd, temp_name = tempfile.mkstemp(+ prefix=f".{path.stem}.frame0.",+ suffix=path.suffix,+ dir=str(path.parent),+ )+ os.close(fd)+ temp_path = Path(temp_name)+ try:+ frame.save(temp_path, "JPEG", **save_kwargs)+ os.replace(temp_path, path)+ except (OSError, ValueError):+ try:+ temp_path.unlink(missing_ok=True)+ except OSError:+ pass+ return False+ finally:+ frame.close()+ return True++def _stage_and_validate_image(output_path: Path,materialize: Callable[[Path], object],@@ -455,6 +508,11 @@ def _stage_and_validate_image(keep_temp = Falsetry:materialize(temp_path)+ if _normalize_multi_frame_jpeg(temp_path):+ print(+ " normalized a multi-frame camera JPEG (MPO) to its primary frame",+ file=sys.stderr,+ )if not _validate_downloaded_quality(temp_path,min_width=min_width,diff --git a/skills/ppt-master/scripts/image_treat.py b/skills/ppt-master/scripts/image_treat.pyindex a1f2b612..21eeae11 100644--- a/skills/ppt-master/scripts/image_treat.py+++ b/skills/ppt-master/scripts/image_treat.py@@ -332,9 +332,14 @@ def _apply_treatments(try:with Image.open(source_path) as source:if int(getattr(source, "n_frames", 1)) != 1:- raise RuntimeError(- f"animated or multi-frame images are unsupported: {source_path}"- )+ if (source.format or "").upper() == "MPO":+ # A camera multi-picture JPEG: the primary frame is the+ # photograph; the sibling frames are stereo/preview data.+ source.seek(0)+ else:+ raise RuntimeError(+ f"animated images are unsupported: {source_path}"+ )oriented = ImageOps.exif_transpose(source)try:oriented.load()diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.pyindex 75cb23dc..78a9f45b 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py@@ -306,6 +306,10 @@ def _valid_project_image_payload(img_format: str, img_data: bytes) -> bool:image.verify()except (UnidentifiedImageError, OSError, ValueError, SyntaxError):return False+ if expected == 'JPEG' and actual == 'MPO':+ # A camera multi-picture JPEG is a JPEG stream followed by sibling+ # frames; every JPEG decoder renders its primary frame.+ return Truereturn actual == expecteddiff --git a/skills/ppt-master/scripts/tests/test_image_search.py b/skills/ppt-master/scripts/tests/test_image_search.pyindex 933f8be9..e0b642ad 100644--- a/skills/ppt-master/scripts/tests/test_image_search.py+++ b/skills/ppt-master/scripts/tests/test_image_search.py@@ -91,3 +91,22 @@ class ImageSearchPromotionTests(unittest.TestCase):if __name__ == "__main__":unittest.main()+++class CandidatePoolContinuationTests(unittest.TestCase):+ def test_multi_frame_camera_jpeg_keeps_its_primary_frame(self) -> None:+ try:+ from PIL import Image+ except ImportError: # pragma: no cover - Pillow is a runtime dependency+ self.skipTest("Pillow unavailable")+ with tempfile.TemporaryDirectory() as temp_dir:+ path = Path(temp_dir) / "camera.jpg"+ first = Image.new("RGB", (64, 48), (200, 20, 20))+ second = Image.new("RGB", (64, 48), (20, 20, 200))+ first.save(path, format="MPO", save_all=True, append_images=[second])+ self.assertTrue(image_search._normalize_multi_frame_jpeg(path))+ with Image.open(path) as image:+ self.assertEqual(image.format, "JPEG")+ self.assertEqual(getattr(image, "n_frames", 1), 1)+ self.assertGreater(image.getpixel((3, 3))[0], 150)+ self.assertFalse(image_search._normalize_multi_frame_jpeg(path))