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(svg-effects): preserve picture shadows and glows
hugohe3fb4475cdac37
diff --git a/skills/ppt-master/scripts/pptx_to_svg/pic_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/pic_to_svg.pyindex 04f14b54..d6325225 100644--- a/skills/ppt-master/scripts/pptx_to_svg/pic_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/pic_to_svg.py@@ -510,8 +510,8 @@ def _apply_blip_image_effects() -> tuple[str, bytes, tuple[PictureDiagnostic, ...]]:"""Bake supported DrawingML blip effects into extracted image bytes.- Keeping the SVG as a plain <image> avoids introducing CSS filters that the- downstream native PPTX converter cannot reliably map back to DrawingML.+ Brightness and contrast are pixel operations, not picture-shape+ shadow/glow effects, so preserve them in the extracted bitmap."""lum_effects = blip.findall("a:lum", NS)if not lum_effects:diff --git a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.pyindex 04e23192..66b1a844 100644--- a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py@@ -964,22 +964,36 @@ def _convert_picture(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool)return ""_diagnose_picture_result(ctx, result)ctx.media.update(result.media)- effect_metadata = unsupported_target_effect_metadata(+ effect = convert_effects(sp_pr,- "picture",+ ctx.palette,+ id_prefix="fx",+ id_seq=ctx.filter_seq,)+ ctx.defs.extend(effect.defs)+ effect_metadata = dict(effect.metadata)_diagnose_unsupported_effect(ctx, effect_metadata)clipped_svg = _clip_blip_image(result.svg, geom, ctx)+ picture_attrs = {**_object_metadata(node, ctx), **effect_metadata}+ group_attrs = _metadata_group_attrs(effect_metadata)+ if effect.filter_id is not None:+ filter_attr = f"url(#{effect.filter_id})"+ if clipped_svg.startswith("<svg"):+ # Keep the effect outside the crop viewport so shadows and glows+ # remain visible beyond the picture frame in SVG previews.+ group_attrs.append(f'filter="{filter_attr}"')+ else:+ picture_attrs["filter"] = filter_attrpicture_svg = _inject_root_svg_attrs(clipped_svg,- {**_object_metadata(node, ctx), **effect_metadata},+ picture_attrs,)return _wrap_shape_group(picture_svg,node,ctx,top_level=top_level,- extra_attrs=_metadata_group_attrs(effect_metadata),+ extra_attrs=group_attrs,)diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.pyindex ef7565c5..916cfc07 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py@@ -51,6 +51,7 @@ from .utils import (_extract_inheritable_styles,_get_attr,_is_unit_axis_reflection,+ is_imported_picture_crop_effect_carrier,parse_svg_length,parse_transform_operations,parse_transform_matrix,@@ -860,11 +861,19 @@ def convert_g(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:or elem.get('data-pptx-geometry-kind') == 'custom'))+ logical_picture_effect_group = (+ filter_id is not None+ and is_imported_picture_crop_effect_carrier(elem)+ )explicit_native_group = elem.get('data-pptx-object') == 'group'if (len(child_results) == 1and not explicit_native_group- and (not should_animate_group or logical_native_shape_group)+ and (+ not should_animate_group+ or logical_native_shape_group+ or logical_picture_effect_group+ )):if should_animate_group and elem_id:shape_match = re.search(r'<p:cNvPr id="(\d+)"', child_results[0].xml)diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.pyindex f4ea9f1b..e410e700 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py@@ -4350,6 +4350,13 @@ def convert_image(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:# Resolve clip-path → DrawingML geometryclip_geom = _resolve_clip_geometry(elem, ctx, raw_x, raw_y, raw_w, raw_h)+ effect_xml = ''+ filter_id = get_effective_filter_id(elem, ctx)+ if filter_id and filter_id in ctx.defs:+ effect_xml = build_effect_xml(+ ctx.defs[filter_id],+ get_element_opacity(elem, ctx),+ )# Resolve preserveAspectRatio="<align> slice" as DrawingML crop metadata.# Image optimization only downscales the full source image; it never crops@@ -4419,6 +4426,7 @@ def convert_image(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:<a:xfrm{xfrm_attr}><a:off x="{off_x}" y="{off_y}"/><a:ext cx="{ext_cx}" cy="{ext_cy}"/></a:xfrm>{clip_geom}+{effect_xml}</p:spPr></p:pic>''', bounds_emu=bounds_emu)@@ -4987,6 +4995,13 @@ def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult:svg_w,svg_h,)+ effect_xml = ''+ filter_id = get_effective_filter_id(elem, ctx)+ if filter_id and filter_id in ctx.defs:+ effect_xml = build_effect_xml(+ ctx.defs[filter_id],+ get_element_opacity(elem, ctx),+ )blip_xml = _build_image_blip_xml(r_id,get_element_opacity(image_elem, ctx),@@ -5006,5 +5021,6 @@ def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult:<a:xfrm{xfrm_attr}><a:off x="{off_x}" y="{off_y}"/><a:ext cx="{ext_cx}" cy="{ext_cy}"/></a:xfrm>{clip_geom}+{effect_xml}</p:spPr></p:pic>''', bounds_emu=bounds_emu)diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.pyindex c1b60bb6..42cd6d7c 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py@@ -245,7 +245,13 @@ PROJECT_FILTER_EFFECT_PRIMITIVES = frozenset({'feDropShadow','feGaussianBlur',})-PROJECT_FILTER_PUBLIC_TARGETS = frozenset({'rect', 'circle', 'path', 'text'})+PROJECT_FILTER_PUBLIC_TARGETS = frozenset({+ 'rect',+ 'circle',+ 'image',+ 'path',+ 'text',+})_PROJECT_MARKER_NUMBER_TOKEN = (r'[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?')@@ -2632,10 +2638,11 @@ def project_filter_errors(root: ET.Element) -> list[str]:if (tag not in PROJECT_FILTER_PUBLIC_TARGETSand not _is_imported_preset_preview_filter_target(elem, parents)+ and not is_imported_picture_crop_effect_carrier(elem)):errors.add(f'{label} cannot use filter; supported native targets are '- 'rect, circle, path, and text'+ 'rect, circle, image, path, and text')match = re.fullmatch(r'url\(#([^)]+)\)', raw_filter.strip())if match is None:@@ -2850,6 +2857,36 @@ def _is_imported_preset_preview_filter_target()+def is_imported_picture_crop_effect_carrier(elem: ET.Element) -> bool:+ """Recognize the private effect carrier around an imported picture crop."""+ if (+ _svg_element_tag(elem) != 'g'+ or elem.get('data-pptx-object') != 'picture'+ ):+ return False+ children = [+ child for child in elem+ if _svg_element_tag(child) not in PROJECT_NON_VISUAL_DEFINITION_CHILD_TAGS+ ]+ if len(children) != 1:+ return False+ crop = children[0]+ if (+ _svg_element_tag(crop) != 'svg'+ or crop.get('data-pptx-object') != 'picture'+ or crop.get('viewBox') is None+ or crop.get('preserveAspectRatio') != 'none'+ or crop.get('filter') is not None+ or crop.get('data-pptx-shape-id') != elem.get('data-pptx-shape-id')+ ):+ return False+ crop_children = list(crop)+ return (+ len(crop_children) == 1+ and _svg_element_tag(crop_children[0]) == 'image'+ )++def parse_hex_color(color_str: str) -> str | None:"""Parse SVG color values to ``RRGGBB``, ignoring any alpha channel."""if color_str and color_str.strip().lower() == 'transparent':