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): honor image transform matrices
hugohe3308363a6035f
diff --git a/skills/ppt-master/scripts/svg_editor/static/app.js b/skills/ppt-master/scripts/svg_editor/static/app.jsindex d80182b8..fa48ab75 100644--- a/skills/ppt-master/scripts/svg_editor/static/app.js+++ b/skills/ppt-master/scripts/svg_editor/static/app.js@@ -54,6 +54,8 @@err_empty_svg: "Slide loaded but the canvas is empty. The SVG may be malformed or missing a root <svg> element.",warn_icon_inline: "{count} icon(s) failed to render: {names}",warn_svg_no_dims: "SVG is missing width/height attributes. Please ask the AI to strictly follow shared-standards.md §4 and include width & height in the SVG root element.",+ warn_matrix_transform: "This geometry edit is stored as a transform matrix. Preview is exact; PPTX export depends on matrix-aware conversion.",+ modal_matrix_transform_note: "\n\nNote: at least one staged geometry edit uses a transform matrix. Re-export with the current PPTX exporter so the matrix is applied.",slide_error_tooltip: "Failed to parse this slide: ",reload_banner: "This slide was updated on disk. Click to reload.",modal_confirm_submit: "Apply staged attribute edits and annotations to disk?\n\nThe preview service will keep running. Click Exit preview when you want to stop it.",@@ -116,6 +118,8 @@err_empty_svg: "幻灯片已加载但画布为空。SVG 可能损坏或缺少根 <svg> 元素。",warn_icon_inline: "{count} 个图标渲染失败:{names}",warn_svg_no_dims: "SVG 缺少 width/height 属性,预览可能异常。请让 AI 严格遵守 shared-standards.md §4 规范,在 SVG 根元素中补全 width 和 height。",+ warn_matrix_transform: "本次几何修改会以 transform matrix 保存。预览是准确的;PPTX 导出需要使用支持 matrix 的当前导出器。",+ modal_matrix_transform_note: "\n\n提示:至少有一条暂存几何修改使用了 transform matrix。请用当前 PPTX 导出器重新导出,确保 matrix 被应用。",slide_error_tooltip: "该幻灯片解析失败:",reload_banner: "当前页已在磁盘上更新,点此重新加载。",modal_confirm_submit: "确认将暂存属性修改和标注写入磁盘?\n\n预览服务会继续运行。需要关闭时请点击退出预览。",@@ -224,6 +228,8 @@var reloadBannerEl = null; // singleton banner element shown when currentSlide mtime driftsvar editStackCount = {}; // {name: staged edit count} — mirrors backend PENDING_EDITSvar savedHintShown = false; // show the "staged edit" hint once per session+ var matrixHintShown = false; // show transform-matrix export hint once per session+ var matrixEditSlides = {}; // {name: true} when a staged edit wrote transform=matrix(...)var annotationsDirty = false; // unsaved annotations added/removed this session// Staged edits live in server memory until "Apply changes"; the server can@@ -1366,7 +1372,8 @@// ================================================================btnSave.addEventListener("click", function () {pendingModalAction = "submit";- modalMessage.textContent = t("modal_confirm_submit");+ modalMessage.textContent = t("modal_confirm_submit") ++ (hasPendingMatrixEdits() ? t("modal_matrix_transform_note") : "");modalConfirm.textContent = t("modal_submit");modalConfirm.style.display = "";modalCancel.style.display = "";@@ -1416,6 +1423,8 @@} else {modalMessage.textContent = t("modal_success_submit");editStackCount = {};+ matrixEditSlides = {};+ matrixHintShown = false;savedHintShown = false;annotationsDirty = false;updateUndoButton();@@ -1561,6 +1570,7 @@.then(function (data) {if (data.status === "empty") {editStackCount[currentSlide] = 0;+ matrixEditSlides[currentSlide] = false;updateUndoButton();showWarning(t("undo_empty"));return;@@ -1585,6 +1595,24 @@showWarning(t("edit_saved_hint"));}+ function payloadHasMatrixTransform(payload) {+ var transform = payload && payload.attrs && payload.attrs.transform;+ return typeof transform === "string" && /^\s*matrix\s*\(/i.test(transform);+ }++ function hasPendingMatrixEdits() {+ return Object.keys(matrixEditSlides).some(function (name) {+ return !!matrixEditSlides[name];+ });+ }++ function markMatrixTransformEdit(slide) {+ matrixEditSlides[slide] = true;+ if (matrixHintShown) return;+ matrixHintShown = true;+ showWarning(t("warn_matrix_transform"));+ }+// ================================================================// Property extraction & rendering// ================================================================@@ -2239,6 +2267,9 @@editStackCount[slide] = data.undo_depth;if (slide === currentSlide) updateUndoButton();}+ if (payloadHasMatrixTransform(payload)) {+ markMatrixTransformEdit(slide);+ }maybeShowSavedHint();return data;});diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.pyindex b58245b3..53c68faa 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py@@ -292,7 +292,7 @@ _NON_VISUAL_TAGS = frozenset(('defs', 'title', 'desc', 'metadata', 'style'))def _supports_matrix_transform(elem: ET.Element) -> bool:"""Return whether this subtree can consume a full affine matrix directly."""tag = elem.tag.replace(f'{{{SVG_NS}}}', '')- if tag == 'image':+ if tag in {'rect', 'circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'image'}:return Trueif tag == 'svg':visual_children = [diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.pyindex e7d0c5bf..c1179f61 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py@@ -19,7 +19,7 @@ from .drawingml_utils import (parse_hex_color, resolve_url_id, get_effective_filter_id,parse_font_family, is_cjk_char, estimate_text_width,detect_text_lang, resolve_text_run_fonts,- parse_transform_matrix, _xml_escape,+ matrix_multiply, parse_transform_matrix, transform_point, _xml_escape,)from .drawingml_styles import (build_solid_fill, build_gradient_fill,@@ -59,16 +59,18 @@ def _wrap_shape(geom_xml: str, fill_xml: str, stroke_xml: str,effect_xml: str = '', extra_xml: str = '',rot: int = 0,+ xfrm_attr: str = '',) -> str:"""Wrap DrawingML content into a <p:sp> shape element."""rot_attr = f' rot="{rot}"' if rot else ''+ xfrm_attrs = f'{xfrm_attr}{rot_attr}'return f'''<p:sp><p:nvSpPr><p:cNvPr id="{shape_id}" name="{_xml_escape(name)}"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr><p:spPr>-<a:xfrm{rot_attr}><a:off x="{off_x}" y="{off_y}"/><a:ext cx="{ext_cx}" cy="{ext_cy}"/></a:xfrm>+<a:xfrm{xfrm_attrs}><a:off x="{off_x}" y="{off_y}"/><a:ext cx="{ext_cx}" cy="{ext_cy}"/></a:xfrm>{geom_xml}{fill_xml}{stroke_xml}@@ -78,6 +80,90 @@ def _wrap_shape(</p:sp>'''+def _context_transform_matrix(ctx: ConvertContext) -> tuple[float, float, float, float, float, float]:+ """Return the current context as a full SVG affine matrix."""+ if ctx.use_transform_matrix:+ return ctx.transform_matrix+ return (+ ctx.scale_x, 0.0,+ 0.0, ctx.scale_y,+ ctx.translate_x, ctx.translate_y,+ )+++def _combined_transform_matrix(+ ctx: ConvertContext,+ transform: str | None,+) -> tuple[float, float, float, float, float, float]:+ """Compose context transform with an element-level transform attribute."""+ matrix = _context_transform_matrix(ctx)+ if transform:+ matrix = matrix_multiply(matrix, parse_transform_matrix(transform))+ return matrix+++def _uses_full_transform(ctx: ConvertContext, transform: str | None) -> bool:+ return ctx.use_transform_matrix or bool(transform)+++def _transformed_point(+ ctx: ConvertContext,+ x: float,+ y: float,+ transform: str | None,+) -> tuple[float, float]:+ if _uses_full_transform(ctx, transform):+ return transform_point(_combined_transform_matrix(ctx, transform), x, y)+ return ctx_x(x, ctx), ctx_y(y, ctx)+++def _shape_xfrm_from_svg_rect(+ ctx: ConvertContext,+ raw_x: float,+ raw_y: float,+ raw_w: float,+ raw_h: float,+ resolved_x: float,+ resolved_y: float,+ resolved_w: float,+ resolved_h: float,+ transform: str | None,+) -> tuple[str, int, int, int, int, tuple[int, int, int, int]]:+ """Build DrawingML xfrm data for an SVG rectangle-like element."""+ if _uses_full_transform(ctx, transform):+ return rect_to_dml_xfrm(+ raw_x, raw_y, raw_w, raw_h,+ _combined_transform_matrix(ctx, transform),+ )++ off_x = px_to_emu(resolved_x)+ off_y = px_to_emu(resolved_y)+ ext_cx = px_to_emu(resolved_w)+ ext_cy = px_to_emu(resolved_h)+ return '', off_x, off_y, ext_cx, ext_cy, (off_x, off_y, off_x + ext_cx, off_y + ext_cy)+++def _transform_path_commands(+ commands: list[PathCommand],+ matrix: tuple[float, float, float, float, float, float],+) -> list[PathCommand]:+ """Apply an affine transform to normalized M/L/C/Z path commands."""+ transformed: list[PathCommand] = []+ for cmd in commands:+ if cmd.cmd in ('M', 'L'):+ x, y = transform_point(matrix, cmd.args[0], cmd.args[1])+ transformed.append(PathCommand(cmd.cmd, [x, y]))+ elif cmd.cmd == 'C':+ args: list[float] = []+ for i in range(0, 6, 2):+ x, y = transform_point(matrix, cmd.args[i], cmd.args[i + 1])+ args.extend([x, y])+ transformed.append(PathCommand(cmd.cmd, args))+ else:+ transformed.append(cmd)+ return transformed++# ---------------------------------------------------------------------------# rect# ---------------------------------------------------------------------------@@ -215,10 +301,14 @@ def convert_rect(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:for now — current corpora contain none, but the branch keeps callers fromsilently producing distorted custom geometry if one ever appears."""- x = ctx_x(_f(elem.get('x')), ctx)- y = ctx_y(_f(elem.get('y')), ctx)- w = ctx_w(_f(elem.get('width')), ctx)- h = ctx_h(_f(elem.get('height')), ctx)+ raw_x = _f(elem.get('x'))+ raw_y = _f(elem.get('y'))+ raw_w = _f(elem.get('width'))+ raw_h = _f(elem.get('height'))+ x = ctx_x(raw_x, ctx)+ y = ctx_y(raw_y, ctx)+ w = ctx_w(raw_w, ctx)+ h = ctx_h(raw_h, ctx)if w <= 0 or h <= 0:return None@@ -247,12 +337,7 @@ def convert_rect(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:if filt_id and filt_id in ctx.defs:effect = build_effect_xml(ctx.defs[filt_id])- rot = 0transform = elem.get('transform')- if transform:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)if rx > 0 and abs(rx - ry) < 0.5:# Symmetric corners → native PowerPoint rounded rectangle. adj is@@ -279,17 +364,25 @@ def convert_rect(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:geom = '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>'shape_id = ctx.next_id()- off_x = px_to_emu(x)- off_y = px_to_emu(y)- ext_cx = px_to_emu(w)- ext_cy = px_to_emu(h)+ xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _shape_xfrm_from_svg_rect(+ ctx,+ raw_x,+ raw_y,+ raw_w,+ raw_h,+ x,+ y,+ w,+ h,+ transform,+ )return ShapeResult(xml=_wrap_shape(shape_id, f'Rectangle {shape_id}',off_x, off_y, ext_cx, ext_cy,- geom, fill, stroke, effect, rot=rot,+ geom, fill, stroke, effect, xfrm_attr=xfrm_attr,),- bounds_emu=(off_x, off_y, off_x + ext_cx, off_y + ext_cy),+ bounds_emu=bounds_emu,)@@ -461,6 +554,7 @@ def convert_circle(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:)# --- Normal circle ---+ transform = elem.get('transform')cx_s = ctx_x(cx_, ctx)cy_s = ctx_y(cy_, ctx)r_x = r * ctx.scale_x@@ -484,17 +578,25 @@ def convert_circle(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:geom = '<a:prstGeom prst="ellipse"><a:avLst/></a:prstGeom>'shape_id = ctx.next_id()- off_x = px_to_emu(x)- off_y = px_to_emu(y)- ext_cx = px_to_emu(w)- ext_cy = px_to_emu(h)+ xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _shape_xfrm_from_svg_rect(+ ctx,+ cx_ - r,+ cy_ - r,+ r * 2,+ r * 2,+ x,+ y,+ w,+ h,+ transform,+ )return ShapeResult(xml=_wrap_shape(shape_id, f'Ellipse {shape_id}',off_x, off_y, ext_cx, ext_cy,- geom, fill, stroke, effect,+ geom, fill, stroke, effect, xfrm_attr=xfrm_attr,),- bounds_emu=(off_x, off_y, off_x + ext_cx, off_y + ext_cy),+ bounds_emu=bounds_emu,)@@ -510,10 +612,9 @@ def convert_line(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:heads (headEnd / tailEnd) correctly. Plain lines (no markers) continue touse custom geometry which is sufficient and avoids flipH/flipV complexity."""- x1 = ctx_x(_f(elem.get('x1')), ctx)- y1 = ctx_y(_f(elem.get('y1')), ctx)- x2 = ctx_x(_f(elem.get('x2')), ctx)- y2 = ctx_y(_f(elem.get('y2')), ctx)+ transform = elem.get('transform')+ x1, y1 = _transformed_point(ctx, _f(elem.get('x1')), _f(elem.get('y1')), transform)+ x2, y2 = _transformed_point(ctx, _f(elem.get('x2')), _f(elem.get('y2')), transform)min_x = min(x1, x2)min_y = min(y1, y2)@@ -521,13 +622,6 @@ def convert_line(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:stroke_op = get_stroke_opacity(elem, ctx)stroke = build_stroke_xml(elem, ctx, stroke_op)- rot = 0- transform = elem.get('transform')- if transform:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)-shape_id = ctx.next_id()off_x = px_to_emu(min_x)off_y = px_to_emu(min_y)@@ -572,7 +666,6 @@ def convert_line(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:elif flip_v:flip_attr = ' flipV="1"'- rot_attr = f' rot="{rot}"' if rot else ''xml = (f'<p:sp>'f'<p:nvSpPr>'@@ -580,7 +673,7 @@ def convert_line(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:f'<p:cNvSpPr/><p:nvPr/>'f'</p:nvSpPr>'f'<p:spPr>'- f'<a:xfrm{flip_attr}{rot_attr}>'+ f'<a:xfrm{flip_attr}>'f'<a:off x="{off_x}" y="{off_y}"/>'f'<a:ext cx="{w_emu}" cy="{h_emu}"/>'f'</a:xfrm>'@@ -617,7 +710,7 @@ def convert_line(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:xml = _wrap_shape(shape_id, f'Line {shape_id}',off_x, off_y, w_emu, h_emu,- geom, '<a:noFill/>', stroke, rot=rot,+ geom, '<a:noFill/>', stroke,)return ShapeResult(@@ -640,22 +733,17 @@ def convert_path(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:commands = svg_path_to_absolute(commands)commands = normalize_path_commands(commands)- tx, ty = 0.0, 0.0- rot = 0transform = elem.get('transform')- if transform:- t_match = re.search(r'translate\(\s*([-\d.]+)[\s,]+([-\d.]+)\s*\)', transform)- if t_match:- tx = float(t_match.group(1))- ty = float(t_match.group(2))- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)-- path_xml, min_x, min_y, width, height = path_commands_to_drawingml(- commands, ctx.translate_x + tx, ctx.translate_y + ty,- ctx.scale_x, ctx.scale_y,- )+ if _uses_full_transform(ctx, transform):+ commands = _transform_path_commands(commands, _combined_transform_matrix(ctx, transform))+ path_xml, min_x, min_y, width, height = path_commands_to_drawingml(+ commands, 0, 0, 1.0, 1.0,+ )+ else:+ path_xml, min_x, min_y, width, height = path_commands_to_drawingml(+ commands, ctx.translate_x, ctx.translate_y,+ ctx.scale_x, ctx.scale_y,+ )if not path_xml:return None@@ -663,7 +751,7 @@ def convert_path(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:w_emu = px_to_emu(width)h_emu = px_to_emu(height)- geom = _build_preset_geom_from_meta(elem)+ geom = None if _uses_full_transform(ctx, transform) else _build_preset_geom_from_meta(elem)if geom is None:geom = f'''<a:custGeom><a:avLst/><a:gdLst/><a:ahLst/><a:cxnLst/>@@ -690,7 +778,7 @@ def convert_path(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:xml=_wrap_shape(shape_id, f'Freeform {shape_id}',off_x, off_y, w_emu, h_emu,- geom, fill, stroke, effect, rot=rot,+ geom, fill, stroke, effect,),bounds_emu=(off_x, off_y, off_x + w_emu, off_y + h_emu),)@@ -719,10 +807,17 @@ def convert_polygon(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonecommands.append(PathCommand('L', [px_, py_]))commands.append(PathCommand('Z', []))- path_xml, min_x, min_y, width, height = path_commands_to_drawingml(- commands, ctx.translate_x, ctx.translate_y,- ctx.scale_x, ctx.scale_y,- )+ transform = elem.get('transform')+ if _uses_full_transform(ctx, transform):+ commands = _transform_path_commands(commands, _combined_transform_matrix(ctx, transform))+ path_xml, min_x, min_y, width, height = path_commands_to_drawingml(+ commands, 0, 0, 1.0, 1.0,+ )+ else:+ path_xml, min_x, min_y, width, height = path_commands_to_drawingml(+ commands, ctx.translate_x, ctx.translate_y,+ ctx.scale_x, ctx.scale_y,+ )if not path_xml:return None@@ -743,13 +838,6 @@ def convert_polygon(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonefill = build_fill_xml(elem, ctx, fill_op)stroke = build_stroke_xml(elem, ctx, stroke_op)- rot = 0- transform = elem.get('transform')- if transform:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)-shape_id = ctx.next_id()off_x = px_to_emu(min_x)off_y = px_to_emu(min_y)@@ -757,7 +845,7 @@ def convert_polygon(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonexml=_wrap_shape(shape_id, f'Polygon {shape_id}',off_x, off_y, w_emu, h_emu,- geom, fill, stroke, rot=rot,+ geom, fill, stroke,),bounds_emu=(off_x, off_y, off_x + w_emu, off_y + h_emu),)@@ -773,10 +861,17 @@ def convert_polyline(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonfor px_, py_ in points[1:]:commands.append(PathCommand('L', [px_, py_]))- path_xml, min_x, min_y, width, height = path_commands_to_drawingml(- commands, ctx.translate_x, ctx.translate_y,- ctx.scale_x, ctx.scale_y,- )+ transform = elem.get('transform')+ if _uses_full_transform(ctx, transform):+ commands = _transform_path_commands(commands, _combined_transform_matrix(ctx, transform))+ path_xml, min_x, min_y, width, height = path_commands_to_drawingml(+ commands, 0, 0, 1.0, 1.0,+ )+ else:+ path_xml, min_x, min_y, width, height = path_commands_to_drawingml(+ commands, ctx.translate_x, ctx.translate_y,+ ctx.scale_x, ctx.scale_y,+ )if not path_xml:return None@@ -797,13 +892,6 @@ def convert_polyline(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonfill = build_fill_xml(elem, ctx, fill_op)stroke = build_stroke_xml(elem, ctx, stroke_op)- rot = 0- transform = elem.get('transform')- if transform:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)-shape_id = ctx.next_id()off_x = px_to_emu(min_x)off_y = px_to_emu(min_y)@@ -811,7 +899,7 @@ def convert_polyline(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonxml=_wrap_shape(shape_id, f'Polyline {shape_id}',off_x, off_y, w_emu, h_emu,- geom, '<a:noFill/>', stroke, rot=rot,+ geom, '<a:noFill/>', stroke,),bounds_emu=(off_x, off_y, off_x + w_emu, off_y + h_emu),)@@ -1664,6 +1752,41 @@ def _picture_xfrm_from_rect(return '', off_x, off_y, ext_cx, ext_cy, (off_x, off_y, off_x + ext_cx, off_y + ext_cy)+def _picture_xfrm_from_svg_rect(+ ctx: ConvertContext,+ raw_x: float,+ raw_y: float,+ raw_w: float,+ raw_h: float,+ resolved_x: float,+ resolved_y: float,+ resolved_w: float,+ resolved_h: float,+ transform: str | None,+) -> tuple[str, int, int, int, int, tuple[int, int, int, int]]:+ """Build picture xfrm data, honoring element-level SVG transforms.++ ``raw_*`` values stay in the element's source SVG coordinate space for+ matrix decomposition; ``resolved_*`` values are the existing scalar path.+ """+ if ctx.use_transform_matrix:+ matrix = ctx.transform_matrix+ if transform:+ matrix = matrix_multiply(matrix, parse_transform_matrix(transform))+ return rect_to_dml_xfrm(raw_x, raw_y, raw_w, raw_h, matrix)++ if transform:+ context_matrix = (+ ctx.scale_x, 0.0,+ 0.0, ctx.scale_y,+ ctx.translate_x, ctx.translate_y,+ )+ matrix = matrix_multiply(context_matrix, parse_transform_matrix(transform))+ return rect_to_dml_xfrm(raw_x, raw_y, raw_w, raw_h, matrix)++ return _picture_xfrm_from_rect(ctx, resolved_x, resolved_y, resolved_w, resolved_h)++def _read_image_size(data: bytes) -> tuple[int | None, int | None]:"""Read intrinsic image dimensions (width, height) from raw bytes.@@ -1879,13 +2002,7 @@ def convert_image(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:'target': f'../media/{img_filename}',})- rot = 0transform = elem.get('transform')- if transform and not ctx.use_transform_matrix:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)- rot_attr = f' rot="{rot}"' if rot else ''# Resolve clip-path → DrawingML geometryclip_geom = _resolve_clip_geometry(elem, ctx, raw_x, raw_y, raw_w, raw_h)@@ -1908,15 +2025,41 @@ def convert_image(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:shape_id = ctx.next_id()if meet_fit is not None:dx, dy, fit_w, fit_h = meet_fit- xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _picture_xfrm_from_rect(- ctx, x + dx, y + dy, fit_w, fit_h,+ if ctx.use_transform_matrix:+ raw_fit_x = raw_x + dx+ raw_fit_y = raw_y + dy+ raw_fit_w = fit_w+ raw_fit_h = fit_h+ else:+ raw_fit_x = raw_x + (dx / ctx.scale_x if ctx.scale_x else dx)+ raw_fit_y = raw_y + (dy / ctx.scale_y if ctx.scale_y else dy)+ raw_fit_w = fit_w / ctx.scale_x if ctx.scale_x else fit_w+ raw_fit_h = fit_h / ctx.scale_y if ctx.scale_y else fit_h+ xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _picture_xfrm_from_svg_rect(+ ctx,+ raw_fit_x,+ raw_fit_y,+ raw_fit_w,+ raw_fit_h,+ x + dx,+ y + dy,+ fit_w,+ fit_h,+ transform,)else:- xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _picture_xfrm_from_rect(- ctx, x, y, w, h,+ xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _picture_xfrm_from_svg_rect(+ ctx,+ raw_x,+ raw_y,+ raw_w,+ raw_h,+ x,+ y,+ w,+ h,+ transform,)- if rot_attr:- xfrm_attr += rot_attrreturn ShapeResult(xml=f'''<p:pic><p:nvPicPr>@@ -1942,10 +2085,14 @@ def convert_image(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:def convert_ellipse(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:"""Convert SVG <ellipse> to DrawingML ellipse shape."""- cx_ = ctx_x(_f(elem.get('cx')), ctx)- cy_ = ctx_y(_f(elem.get('cy')), ctx)- rx = _f(elem.get('rx')) * ctx.scale_x- ry = _f(elem.get('ry')) * ctx.scale_y+ raw_cx = _f(elem.get('cx'))+ raw_cy = _f(elem.get('cy'))+ raw_rx = _f(elem.get('rx'))+ raw_ry = _f(elem.get('ry'))+ cx_ = ctx_x(raw_cx, ctx)+ cy_ = ctx_y(raw_cy, ctx)+ rx = raw_rx * ctx.scale_x+ ry = raw_ry * ctx.scale_yif rx <= 0 or ry <= 0:return None@@ -1962,25 +2109,28 @@ def convert_ellipse(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonegeom = '<a:prstGeom prst="ellipse"><a:avLst/></a:prstGeom>'- rot = 0transform = elem.get('transform')- if transform:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)shape_id = ctx.next_id()- off_x = px_to_emu(x)- off_y = px_to_emu(y)- ext_cx = px_to_emu(w)- ext_cy = px_to_emu(h)+ xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _shape_xfrm_from_svg_rect(+ ctx,+ raw_cx - raw_rx,+ raw_cy - raw_ry,+ raw_rx * 2,+ raw_ry * 2,+ x,+ y,+ w,+ h,+ transform,+ )return ShapeResult(xml=_wrap_shape(shape_id, f'Ellipse {shape_id}',off_x, off_y, ext_cx, ext_cy,- geom, fill, stroke, rot=rot,+ geom, fill, stroke, xfrm_attr=xfrm_attr,),- bounds_emu=(off_x, off_y, off_x + ext_cx, off_y + ext_cy),+ bounds_emu=bounds_emu,)@@ -2076,20 +2226,21 @@ def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | N'target': f'../media/{img_filename}',})- rot = 0transform = elem.get('transform')- if transform and not ctx.use_transform_matrix:- r_match = re.search(r'rotate\(\s*([-\d.]+)', transform)- if r_match:- rot = int(float(r_match.group(1)) * ANGLE_UNIT)- rot_attr = f' rot="{rot}"' if rot else ''shape_id = ctx.next_id()- xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _picture_xfrm_from_rect(- ctx, x, y, w, h,+ xfrm_attr, off_x, off_y, ext_cx, ext_cy, bounds_emu = _picture_xfrm_from_svg_rect(+ ctx,+ svg_x,+ svg_y,+ svg_w,+ svg_h,+ x,+ y,+ w,+ h,+ transform,)- if rot_attr:- xfrm_attr += rot_attrclip_geom = _resolve_clip_geometry(elem, ctx, svg_x, svg_y, svg_w, svg_h)return ShapeResult(xml=f'''<p:pic>