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): keep opaque key-hue foreground intact during pure-key despill
hugohe3c45b7427e707
diff --git a/skills/ppt-master/references/image-generator.md b/skills/ppt-master/references/image-generator.mdindex 824d497f..9790a7f2 100644--- a/skills/ppt-master/references/image-generator.md+++ b/skills/ppt-master/references/image-generator.md@@ -126,7 +126,7 @@ A sheet generates compatible transparent **illustration**, **illustrated-icon**,**Sheet prompt convention** — one `page_role: local` item with `image_size` from final placement; spot sheets `text_policy: none`, lettering sheets `embedded`:- **Grid**: derive `aspect_ratio` and `--grid` from the target shape, not a universal square grid. State an invisible logical **R×C grid** and the cell shape (compact square object, tall portrait, wide vignette, wide lettering mark); center each element in about 65% of its cell and keep at least 10% key-only margin on every side — tips, steam, particles, and effects included — so `slice_images.py --strict-alpha` never meets content on a cell edge. Never draw cells, panels, dividers, borders, frames, or alternate gutter colors; never shrink every subject into a square sticker.-- **Key**: one flat chroma key across the sheet — pure `#00FF00`, `#0000FF`, or `#FF0000`, chosen so its color dominates no element or effect — stated as exact HEX before the palette and the subjects (deck colors appear only inside elements), unchanged in every gutter, free of reflections or spill; grain, halftone, and vignette stay inside elements. The key is technical, not deck palette. Every pixel that is not an element is the key itself — no white card, panel, paper, mat, or frame under an element and no second tint of the key; state the key rule first in the prompt and repeat it last, because a model told only "no borders" still paints each element on a white card.+- **Key**: one flat chroma key across the sheet — pure `#00FF00`, `#0000FF`, or `#FF0000`, chosen so its hue is absent from every element and effect (a pure key despills and recovers soft alpha; an opaque element of the key's hue keeps its color, but thin dark strokes of that hue still fringe) — stated as exact HEX before the palette and the subjects (deck colors appear only inside elements), unchanged in every gutter, free of reflections or spill; grain, halftone, and vignette stay inside elements. The key is technical, not deck palette. Every pixel that is not an element is the key itself — no white card, panel, paper, mat, or frame under an element and no second tint of the key; state the key rule first in the prompt and repeat it last, because a model told only "no borders" still paints each element on a white card.- **Identity**: shared `deck_rendering` + `color_scheme`.- **Illustration / illustrated-icon sheet**: name each element and its page or reuse job; for an icon, the compact cue that must survive at placement size; the §5.3 `none` cue.- **Lettering sheet**: exactly one named stable string per cell as the only text, quoted literally; the group's letterform character and treatment, then role, placement/background relationship, relative weight, and energy under §5.3's controlled-authorship default; artistry glyph-bound (silhouette, stroke structure, material, texture, depth, contour-bound light). No topic motifs, scene fragments, icons, detached ribbons, or particles unless the approved treatment is a lettering-plus-illustration lockup; key-only padding, no scene, unrelated copy, labels, watermark, or mockup surface. A single mark on a wide sheet (3:2 or wider) tends to come back with a faded ghost copy of itself above or below the real mark — give a lone mark a narrow band (about 4:1) that leaves no room for a second line, and inspect every lettering slice for a ghost band, not only for the characters.diff --git a/skills/ppt-master/scripts/docs/image.md b/skills/ppt-master/scripts/docs/image.mdindex 1b902529..e03b19e8 100644--- a/skills/ppt-master/scripts/docs/image.md+++ b/skills/ppt-master/scripts/docs/image.md@@ -160,7 +160,9 @@ Create a non-destructive PNG derivative from one bitmap already prepared undercrop, mask, rotation, mirror, opacity, shadow, scrim, outline, and overlap remainnative SVG/PPT treatments. This tool does not perform semantic backgroundremoval: use `slice_images.py --alpha --bg <key> --strict-alpha` for flat-color-keys (a pure red/green/blue key also recovers soft alpha and removes spill), an+keys (a pure red/green/blue key also recovers soft alpha and removes spill from+key-dominant blends, leaving an opaque foreground of the key's hue untouched; thin+dark strokes of that hue can still fringe, so choose the key by hue absence), analready prepared RGBA asset or the active host image editor for a standalone cutout, and[`image-generator.md`](../../references/image-generator.md) §4.4 only forregistered subject/base layers.diff --git a/skills/ppt-master/scripts/slice_images.py b/skills/ppt-master/scripts/slice_images.pyindex 4d269f0d..1ae504b6 100644--- a/skills/ppt-master/scripts/slice_images.py+++ b/skills/ppt-master/scripts/slice_images.py@@ -68,6 +68,11 @@ _SHEET_DIAGNOSTIC_BUCKET_SIZE = 4# larger tolerance absorbs; farther pixels are content crossing the gutter._KEY_DRIFT_MAX_TOLERANCE = 48_KEY_DRIFT_MARGIN = 4+# A key-dominant pixel whose strongest non-key channel reaches this fraction of+# the key channel is opaque foreground of a key-like hue (malachite green on a+# green key), not a semi-transparent blend with the key; color-to-alpha recovery+# and despill skip it so the element keeps its own color.+_KEY_PURITY_OPAQUE_RATIO = 0.6# At most this many trim pixels on a touched edge count as isolated drift._EDGE_DRIFT_MAX_PIXELS = 8# Corner sample inset (px) and minimum cell fill for the backing-panel notice.@@ -314,13 +319,43 @@ def _chroma_alpha(rgb: Image.Image, bg: tuple[int, int, int]) -> Image.Image:other_channels = [channel for index, channel in enumerate(channels) if index != key_index]- key_excess = ImageChops.subtract(+ key_blend = _key_blend_mask(channels[key_index],ImageChops.lighter(other_channels[0], other_channels[1]),)- key_dominance = key_excess.point(lambda value: 255 if value > 0 else 0)opaque = Image.new("L", rgb.size, 255)- return Image.composite(raw_alpha, opaque, key_dominance)+ return Image.composite(raw_alpha, opaque, key_blend)+++def _key_blend_mask(key_channel: Image.Image, other_max: Image.Image) -> Image.Image:+ """Mask the pixels that read as a blend of foreground with a pure key.++ A pixel qualifies only when the key channel dominates and the strongest+ non-key channel stays below `_KEY_PURITY_OPAQUE_RATIO` of it. An opaque+ foreground color that merely shares the key's hue (a malachite green under a+ green key) keeps a substantial non-key channel and is left opaque, while+ antialiased edges, soft shadows, and glows composited over the key fall+ below the ratio and still receive color-to-alpha recovery.+ """+ ratio_num = round(_KEY_PURITY_OPAQUE_RATIO * 10)+ if hasattr(ImageMath, "lambda_eval"):+ blend = ImageMath.lambda_eval(+ lambda op: op["convert"](+ (op["key"] > op["other"])+ & (op["other"] * 10 < op["key"] * ratio_num),+ "L",+ ),+ key=key_channel,+ other=other_max,+ )+ else:+ blend = ImageMath.eval( # type: ignore[attr-defined]+ "convert((key > other) & (other * 10 < key * ratio), 'L')",+ key=key_channel,+ other=other_max,+ ratio=ratio_num,+ )+ return blend.point(lambda value: 255 if value else 0)def _decontaminate_channel(@@ -800,7 +835,8 @@ def build_parser() -> argparse.ArgumentParser:parser.add_argument("--bg", default=None,help="Background hex color for --trim/--alpha; an exact pure red/green/blue "- "key enables despill and soft-alpha recovery (default: auto-sample)",+ "key enables despill and soft-alpha recovery, skipping opaque "+ "foreground pixels of a key-like hue (default: auto-sample)",)parser.add_argument("--tolerance", type=int, default=18,diff --git a/skills/ppt-master/scripts/tests/test_slice_images.py b/skills/ppt-master/scripts/tests/test_slice_images.pyindex 1ca4ec12..afac0dc1 100644--- a/skills/ppt-master/scripts/tests/test_slice_images.py+++ b/skills/ppt-master/scripts/tests/test_slice_images.py@@ -29,6 +29,31 @@ SCRIPT = SCRIPTS_DIR / "slice_images.py"class SliceImagesDiagnosticsTests(unittest.TestCase):+ def test_pure_key_despill_keeps_opaque_key_hue_foreground_and_recovers_shadow(self) -> None:+ with tempfile.TemporaryDirectory() as tmp:+ root = Path(tmp)+ sheet_path = root / "sheet.png"+ key = (0, 255, 0)+ malachite = (63, 143, 108)+ image = Image.new("RGB", (240, 100), key)+ draw = ImageDraw.Draw(image)+ draw.rectangle((20, 20, 100, 80), fill=malachite)+ # A black shadow composited over the key at 50% alpha.+ draw.rectangle((140, 20, 220, 80), fill=(0, 128, 0))+ image.save(sheet_path)++ written = slice_sheet(+ sheet_path, 1, 1, root / "out",+ names=["element"], alpha=True, bg=key, tolerance=18,+ )+ element = Image.open(written[0]).convert("RGBA")++ self.assertEqual(element.getpixel((60, 50)), malachite + (255,))+ shadow_r, shadow_g, shadow_b, shadow_a = element.getpixel((180, 50))+ self.assertLessEqual(max(shadow_r, shadow_g, shadow_b), 8)+ self.assertTrue(120 <= shadow_a <= 136, shadow_a)+ self.assertEqual(element.getpixel((120, 50))[3], 0)+def test_sheet_orientation_is_applied_before_slicing(self) -> None:for orientation, expected_size in ((6, (40, 80)), (None, (80, 40))):with self.subTest(orientation=orientation), tempfile.TemporaryDirectory() as tmp: