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(svg-to-pptx): require explicit filter geometry

hugohe3422cd03ff024
diff --git a/skills/ppt-master/references/image-layout-patterns.md b/skills/ppt-master/references/image-layout-patterns.md
index 06476304..26f96618 100644
--- a/skills/ppt-master/references/image-layout-patterns.md
+++ b/skills/ppt-master/references/image-layout-patterns.md
@@ -174,9 +174,9 @@ Stack any of these freely on top of a Primary structure. Multiple Modifiers per
35. **Duotone treatment** — two-color mapping of a photograph (e.g. deep navy shadows + warm cream highlights). Bake it into the source image; the native PPT route does not support a runtime duotone filter chain.
-36. **Drop shadow under image panel** — `<filter><feDropShadow dx dy stdDeviation flood-color flood-opacity/></filter>` applied to the image's container `<rect>` (or to the `<image>` itself). Standard depth lift.
+36. **Drop shadow under image panel** — `<filter><feDropShadow dx="0" dy="4" stdDeviation="6" flood-color="#000000" flood-opacity="0.10"/></filter>` applied to the image panel's backing `<rect>`. Standard depth lift; filters do not apply directly to `<image>` under the project contract.
-37. **Inner / outer glow on overlay shape** — `<filter><feGaussianBlur/><feMerge/></filter>` on a shape, or simply a slightly larger blurred `<rect>` underneath the target.
+37. **Inner / outer glow on overlay shape** — `<filter><feGaussianBlur stdDeviation="6"/><feMerge/></filter>` on a shape, or simply a slightly larger blurred `<rect>` underneath the target.
## Image as Texture / Atmosphere
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 914afc84..426aa27f 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -758,6 +758,7 @@ Filters are native-effect metadata, not a general pixel-filter surface.
| Definition/reference | Direct `<defs><filter id="...">` child with unique id; direct `filter="url(#id)"` attribute, never inline style |
| Public targets | `<rect>`, `<circle>`, `<path>`, `<text>` |
| Required primitive | `feDropShadow` or `feGaussianBlur` |
+| Required geometry | Explicit `stdDeviation` on either effect primitive; explicit `dx` and `dy` on `feDropShadow` |
| Accepted helpers | `feOffset`, `feFlood`, `feComposite`, `feMerge`, `feMergeNode`, `feComponentTransfer`, linear `feFuncA` |
| Numeric values | Finite unitless values; non-negative `stdDeviation`; finite `dx` / `dy`; `feFuncA slope` within `0..1`; mapped glow `rad = stdDeviation × 9525`, shadow `blurRad = stdDeviation × 2 × 9525`, and shadow `dist = hypot(dx,dy) × 9525` must round into DrawingML `0..27273042316900` |
| Classification | Meaningful non-zero offset → one outer shadow; zero/no offset → one glow |
@@ -825,8 +826,9 @@ If a shape has both an unsupported shape-level effect and one of these run-level
fallback reasons, the canonical compound marker records both reasons.
This conditional guard is not a public run-effect authoring surface.
The quality checker and exporter preflight enforce the same definition,
-reference, primitive, target, and numeric-value contract; malformed values are
-never replaced by effect defaults during native export.
+reference, primitive, target, and numeric-value contract. Missing required
+geometry and malformed values are never replaced by effect defaults during
+native export.
```xml
<defs>
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py
index 53e7453c..1ba6b52b 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py
@@ -1927,7 +1927,7 @@ def parse_project_filter_params(
filter_elem: ET.Element,
) -> dict[str, float | str | bool]:
"""Extract the shared native shadow/glow parameters from one filter."""
- std_dev = 4.0
+ std_dev: float | None = None
dx = 0.0
dy = 0.0
paint_opacity: float | None = None
@@ -1936,6 +1936,27 @@ def parse_project_filter_params(
color = '000000'
has_offset = False
+ def required_number(primitive: ET.Element, attribute_name: str) -> float:
+ primitive_tag = _svg_element_tag(primitive) or str(primitive.tag)
+ raw_value = primitive.get(attribute_name)
+ if raw_value is None:
+ raise ValueError(
+ f'<{primitive_tag}> requires explicit {attribute_name}'
+ )
+ try:
+ value = float(raw_value)
+ except (TypeError, ValueError) as exc:
+ raise ValueError(
+ f'<{primitive_tag}> {attribute_name} must be a finite number; '
+ f'got {raw_value!r}'
+ ) from exc
+ if not math.isfinite(value):
+ raise ValueError(
+ f'<{primitive_tag}> {attribute_name} must be a finite number; '
+ f'got {raw_value!r}'
+ )
+ return value
+
for child in filter_elem.iter():
tag = _svg_element_tag(child)
style_values = parse_inline_style(child.get('style'))
@@ -1944,9 +1965,9 @@ def parse_project_filter_params(
return style_values.get(name) or child.get(name, default)
if tag == 'feDropShadow':
- std_dev = _f(child.get('stdDeviation'), 4.0)
- dx = _f(child.get('dx'), 0.0)
- dy = _f(child.get('dy'), 0.0)
+ std_dev = required_number(child, 'stdDeviation')
+ dx = required_number(child, 'dx')
+ dy = required_number(child, 'dy')
if abs(dx) > 0.01 or abs(dy) > 0.01:
has_offset = True
paint_opacity = parse_opacity(
@@ -1961,7 +1982,7 @@ def parse_project_filter_params(
color = parsed_color
color_alpha = parsed_alpha
elif tag == 'feGaussianBlur':
- std_dev = _f(child.get('stdDeviation'), 4.0)
+ std_dev = required_number(child, 'stdDeviation')
elif tag == 'feOffset':
dx = _f(child.get('dx'), 0.0)
dy = _f(child.get('dy'), 0.0)
@@ -1995,6 +2016,9 @@ def parse_project_filter_params(
opacity = paint_opacity * transfer_opacity
opacity = max(0.0, min(1.0, opacity * color_alpha))
+ if std_dev is None:
+ raise ValueError('filter requires feDropShadow or feGaussianBlur')
+
return {
'std_dev': std_dev,
'dx': dx,
@@ -2126,18 +2150,30 @@ def project_filter_errors(root: ET.Element) -> list[str]:
for primitive in filter_elem.iter():
primitive_tag = _svg_element_tag(primitive)
- numeric_attrs: tuple[tuple[str, bool], ...] = ()
+ numeric_attrs: tuple[tuple[str, bool, bool], ...] = ()
if primitive_tag in {'feDropShadow', 'feGaussianBlur'}:
- numeric_attrs = (('stdDeviation', True),)
+ numeric_attrs = (('stdDeviation', True, True),)
elif primitive_tag == 'feOffset':
- numeric_attrs = (('dx', False), ('dy', False))
+ numeric_attrs = (
+ ('dx', False, False),
+ ('dy', False, False),
+ )
elif primitive_tag == 'feFuncA':
- numeric_attrs = (('slope', True),)
+ numeric_attrs = (('slope', True, False),)
if primitive_tag == 'feDropShadow':
- numeric_attrs += (('dx', False), ('dy', False))
- for attribute_name, non_negative in numeric_attrs:
+ numeric_attrs += (
+ ('dx', False, True),
+ ('dy', False, True),
+ )
+ for attribute_name, non_negative, required in numeric_attrs:
raw_value = primitive.get(attribute_name)
if raw_value is None:
+ if required:
+ geometry_is_valid = False
+ errors.add(
+ f'{label} <{primitive_tag}> requires explicit '
+ f'{attribute_name}'
+ )
continue
try:
value = float(raw_value)
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 8a4cc1a0..e7c39ca6 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -2508,6 +2508,42 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
'invalid project filter',
)
+ def test_filter_effect_geometry_must_be_explicit(self):
+ cases = (
+ (
+ 'Gaussian blur standard deviation',
+ '<feGaussianBlur/>',
+ '<feGaussianBlur> requires explicit stdDeviation',
+ ),
+ (
+ 'drop shadow standard deviation',
+ '<feDropShadow dx="0" dy="4"/>',
+ '<feDropShadow> requires explicit stdDeviation',
+ ),
+ (
+ 'drop shadow horizontal offset',
+ '<feDropShadow dy="4" stdDeviation="6"/>',
+ '<feDropShadow> requires explicit dx',
+ ),
+ (
+ 'drop shadow vertical offset',
+ '<feDropShadow dx="0" stdDeviation="6"/>',
+ '<feDropShadow> requires explicit dy',
+ ),
+ )
+ for label, primitive, expected in cases:
+ with self.subTest(label=label):
+ self._assert_checker_and_exporter_reject(
+ f'''<svg xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 1280 720">
+ <defs><filter id="effect">{primitive}</filter></defs>
+ <rect x="80" y="80" width="300" height="180"
+ fill="#FFFFFF" filter="url(#effect)"/>
+</svg>''',
+ expected,
+ 'invalid project filter',
+ )
+
def test_filter_coordinates_block_drawingml_overflow(self):
cases = (
(