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(pptx-to-svg): normalize scRGB colors in linear light
hugohe3c1affbe9c5bc
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 0c801bba..55794c34 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -763,6 +763,15 @@ attributes. The registered mapping accepts integer DrawingML units only:or out-of-range channels, extra attributes, namespace aliases, and interleavedtext stop import instead of receiving zero defaults or being clamped into adifferent color.+Imported `a:scrgbClr` has exactly the required `r`, `g`, and `b` attributes,+each using an integer `0..100000` DrawingML channel. Because scRGB channels are+linear-light values while SVG hexadecimal paint is sRGB-encoded, import applies+the sRGB transfer function before quantization; for example, linear+`50000/50000/50000` normalizes to `#BCBCBC`, not `#808080`. Missing, malformed,+percentage-literal, or out-of-range channels, extra attributes, namespace+aliases, and interleaved text stop import instead of receiving zero defaults or+being clamped into another color. This route is `Native-normalized` because the+SVG retains the displayed sRGB color rather than the source color-space model.---diff --git a/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py b/skills/ppt-master/scripts/pptx_to_svg/color_resolver.pyindex 119cb4b9..a3df44d3 100644--- a/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py+++ b/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py@@ -305,11 +305,7 @@ def resolve_color(elif tag == "hslClr":base_hex = _hsl_color_hex(color_elem)elif tag == "scrgbClr":- # 0..100000 per channel- r = float(color_elem.attrib.get("r", "0")) / 100000.0- g = float(color_elem.attrib.get("g", "0")) / 100000.0- b = float(color_elem.attrib.get("b", "0")) / 100000.0- base_hex = _rgb01_to_hex(r, g, b)+ base_hex = _scrgb_color_hex(color_elem)if base_hex is None:return None, 1.0@@ -432,6 +428,30 @@ def _hsl_color_hex(color_elem: ET.Element) -> str:)+def _scrgb_color_hex(color_elem: ET.Element) -> str:+ """Resolve one closed linear-light DrawingML scRGB base color."""+ children = list(color_elem)+ if (+ color_elem.tag != f"{{{NS['a']}}}scrgbClr"+ or set(color_elem.attrib) != {"r", "g", "b"}+ or (color_elem.text or "").strip()+ or any((child.tail or "").strip() for child in children)+ ):+ raise ValueError("Invalid DrawingML scRGB color structure")+ channels = [+ _bounded_integer_attribute(+ color_elem,+ attr,+ minimum=0,+ maximum=100000,+ label="scRGB color",+ )+ / 100000.0+ for attr in ("r", "g", "b")+ ]+ return _linear_rgb01_to_hex(*channels)++def _bounded_integer_attribute(elem: ET.Element,attr: str,@@ -554,6 +574,17 @@ def _rgb01_to_hex(r: float, g: float, b: float) -> str:return f"{int(round(r * 255)):02X}{int(round(g * 255)):02X}{int(round(b * 255)):02X}"+def _linear_rgb01_to_hex(r: float, g: float, b: float) -> str:+ """Encode linear-light RGB channels as an SVG sRGB hex color."""+ encoded = (+ 12.92 * channel+ if channel <= 0.0031308+ else 1.055 * channel ** (1.0 / 2.4) - 0.055+ for channel in (r, g, b)+ )+ return _rgb01_to_hex(*encoded)++def _hsl_to_hex(h: float, s: float, l: float) -> str:h = h % 1.0 if h != 1.0 else 1.0s = max(0.0, min(1.0, s))diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex 2427708e..9ce199c9 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -3185,6 +3185,72 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):</a:hslClr>''')self.assertEqual(resolve_color(valid, None), ('#FF0000', 0.5))+ def test_native_scrgb_color_requires_bounded_linear_channels(self):+ invalid_colors = (+ ('<a:scrgbClr g="50000" b="50000"/>', 'scRGB color structure'),+ (+ '<a:scrgbClr r="50000" g="50000" b="50000" future="x"/>',+ 'scRGB color structure',+ ),+ (+ '<a:scrgbClr r="-1" g="50000" b="50000"/>',+ 'scRGB color r',+ ),+ (+ '<a:scrgbClr r="100001" g="50000" b="50000"/>',+ 'scRGB color r',+ ),+ (+ '<a:scrgbClr r="0.5" g="50000" b="50000"/>',+ 'scRGB color r',+ ),+ (+ '<a:scrgbClr r="50000" g="50%" b="50000"/>',+ 'scRGB color g',+ ),+ (+ '<a:scrgbClr r="50000" g="NaN" b="50000"/>',+ 'scRGB color g',+ ),+ (+ '<a:scrgbClr r="50000" g="50000" b="1e2"/>',+ 'scRGB color b',+ ),+ (+ '<a:scrgbClr r="50000" g="50000" b="50000">payload'+ '</a:scrgbClr>',+ 'scRGB color structure',+ ),+ (+ '<a:scrgbClr r="50000" g="50000" b="50000">'+ '<a:alpha val="50000"/>payload</a:scrgbClr>',+ 'scRGB color structure',+ ),+ )+ namespace = (+ 'xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"'+ )+ for color, expected in invalid_colors:+ with self.subTest(color=color):+ fill = ET.fromstring(+ f'<a:solidFill {namespace}>{color}</a:solidFill>'+ )+ with self.assertRaisesRegex(ValueError, expected):+ resolve_fill(fill, None)++ foreign_color = ET.fromstring(+ '<future:scrgbClr xmlns:future="urn:future" '+ 'r="50000" g="50000" b="50000"/>'+ )+ with self.assertRaisesRegex(ValueError, 'scRGB color structure'):+ resolve_color(foreign_color, None)++ valid = ET.fromstring(f'''+<a:scrgbClr {namespace} r="50000" g="50000" b="50000">+ <a:alpha val="50000"/>+</a:scrgbClr>''')+ self.assertEqual(resolve_color(valid, None), ('#BCBCBC', 0.5))+def test_native_gradient_stop_position_round_trips(self):for position in (0, 1, 7, 13, 33333, 99999, 100000):with self.subTest(position=position):