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(export): cap native PPTX image media size
hugohe377f2c0ba37c9
diff --git a/skills/ppt-master/SKILL.md b/skills/ppt-master/SKILL.mdindex fb2a1be7..90b2b47a 100644--- a/skills/ppt-master/SKILL.md+++ b/skills/ppt-master/SKILL.md@@ -625,10 +625,11 @@ Canonical three-command pipeline (mirrors `references/shared-standards.md` §5):python3 ${SKILL_DIR}/scripts/total_md_split.py <project_path>```-**Step 7.2** — SVG post-processing (icon embedding / image crop & embed / text flattening / rounded rect to path):+**Step 7.2** — SVG post-processing (icon embedding / image crop & embed / raster image optimization / text flattening / rounded rect to path):```bashpython3 ${SKILL_DIR}/scripts/finalize_svg.py <project_path>```+Default raster handling for `svg_final/`: images are embedded at the rendered SVG size budget (`--image-scale 2`, `--max-dimension 2560`), opaque PNG photos may be written as JPEG, and transparent assets remain PNG. Use `--no-compress` or a higher `--max-dimension` only for diagnostic / high-fidelity SVG snapshots.**Step 7.3** — Export PPTX (embeds speaker notes by default):```bash@@ -643,7 +644,16 @@ python3 ${SKILL_DIR}/scripts/svg_to_pptx.py <project_path>> The native pptx consumes `svg_output/` directly so the converter can preserve> high-fidelity primitives (icon `<use>` placeholders, image `preserveAspectRatio`-> → `srcRect`, rounded rect `rx/ry` → `prstGeom roundRect`). The `svg_output/`+> → native picture crop metadata, rounded rect `rx/ry` → `prstGeom roundRect`).+> Native raster images are optimized by default before writing `ppt/media`+> (`--image-sizing cap`, `--image-max-dimension 2560`, `--image-quality 85`).+> This optimization downscales only oversized full source images; it does not+> crop pixels out of embedded PPTX media, and it does not reduce a small+> placement image merely because it is currently displayed small. Display+> cropping remains editable PPT picture-crop metadata. Add `--no-image-optimize`+> only when the deck must retain original image bytes. Use+> `--image-sizing display --image-scale 2` only for aggressive size reduction.+> The `svg_output/`> snapshot in `backup/<timestamp>/` is always written so the project can be> re-exported from frozen SVG sources without re-running the LLM. The SVG-rendered> preview pptx is opt-in via `--svg-snapshot` — live preview already provides thediff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 6299ed94..4b891641 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -299,7 +299,7 @@ Must be executed in order — skipping or adding extra flags is FORBIDDEN:# 1. Split speaker notes into per-page note filespython3 scripts/total_md_split.py <project_path>-# 2. SVG post-processing (icon embedding, image crop/embed, text flattening, rounded rect to path)+# 2. SVG post-processing (icon embedding, image crop/embed/optimization, text flattening, rounded rect to path)python3 scripts/finalize_svg.py <project_path># 3. Export PPTX (embeds speaker notes by default)@@ -339,7 +339,9 @@ Full reference: [`animations.md`](animations.md).- NEVER force `-s output` for the legacy/preview pptx (PowerPoint's internal SVG parser drops icons and rounded corners). Default auto-split already gives native the high-fidelity source it needs without affecting legacy.- NEVER use `--only` (it suppresses one of the two output files)-> Source-directory split: by default `svg_to_pptx.py` reads `svg_output/` for the native pptx (preserves icon `<use>`, image `preserveAspectRatio` → `srcRect`, rounded rect `rx/ry` → `prstGeom roundRect`) and `svg_final/` for the legacy/preview pptx (PowerPoint's internal SVG parser needs the flattened form). Pass `-s output` or `-s final` only when you specifically want both products to read from a single source.+> Source-directory split: by default `svg_to_pptx.py` reads `svg_output/` for the native pptx (preserves icon `<use>`, image `preserveAspectRatio` as native picture-crop metadata, rounded rect `rx/ry` → `prstGeom roundRect`) and `svg_final/` for the legacy/preview pptx (PowerPoint's internal SVG parser needs the flattened form). Pass `-s output` or `-s final` only when you specifically want both products to read from a single source.++**Default — raster size control**: `finalize_svg.py` optimizes raster images using a rendered-size budget of `2x` display pixels with a `2560px` maximum dimension; it may crop pixels for the flattened SVG snapshot. Native `svg_to_pptx.py` defaults to `--image-sizing cap`: it downscales only oversized full source images to `--image-max-dimension 2560`, keeps display cropping as editable PPT picture-crop metadata, and does not shrink a picture merely because its current SVG placement is small. Opaque PNG photos may become JPEG; transparent assets remain PNG. Use `finalize_svg.py --no-compress` / a higher `--max-dimension` only for diagnostic SVG snapshots, `svg_to_pptx.py --no-image-optimize` only when the native PPTX must retain original image bytes, and `svg_to_pptx.py --image-sizing display --image-scale 2` only for aggressive size reduction.**Re-run rule**: Any change to `svg_output/` after post-processing requires re-running Steps 2-3. Step 1 only re-runs if `notes/total.md` changed.diff --git a/skills/ppt-master/scripts/README.md b/skills/ppt-master/scripts/README.mdindex d80b866d..b5d2997f 100644--- a/skills/ppt-master/scripts/README.md+++ b/skills/ppt-master/scripts/README.md@@ -109,6 +109,8 @@ python3 scripts/finalize_svg.py <project_path>python3 scripts/svg_to_pptx.py <project_path>```+`finalize_svg.py` optimizes raster images by default using `2x` display pixels and max `2560px`. Native `svg_to_pptx.py` defaults to `--image-sizing cap`: only oversized full source images are reduced to max `2560px`, so later PowerPoint resizing keeps more image detail. Use `svg_to_pptx.py --image-sizing display --image-scale 2` only for aggressive size reduction, or `--no-image-optimize` when the native PPTX must embed original image bytes.+Image generation:```bashdiff --git a/skills/ppt-master/scripts/finalize_svg.py b/skills/ppt-master/scripts/finalize_svg.pyindex e7ca8111..0846e6aa 100644--- a/skills/ppt-master/scripts/finalize_svg.py+++ b/skills/ppt-master/scripts/finalize_svg.py@@ -118,8 +118,9 @@ def finalize_project(options: dict[str, bool],dry_run: bool = False,quiet: bool = False,- compress: bool = False,- max_dimension: int | None = None,+ compress: bool = True,+ max_dimension: int | None = 2560,+ image_scale: float = 2.0,) -> bool:"""Finalize SVG files in the project@@ -131,6 +132,7 @@ def finalize_project(quiet: Quiet mode, reduce outputcompress: Compress images before embeddingmax_dimension: Downscale images exceeding this dimension+ image_scale: Target image pixels per SVG display pixel"""svg_output = project_dir / 'svg_output'svg_final = project_dir / 'svg_final'@@ -203,6 +205,7 @@ def finalize_project(verbose=False,compress=compress,max_dimension=max_dimension,+ image_scale=image_scale,)img_count += countimg_errors += errs@@ -304,10 +307,14 @@ Aliases (still accepted):help='Preview only, do not execute')parser.add_argument('--quiet', '-q', action='store_true',help='Quiet mode, reduce output')- parser.add_argument('--compress', action='store_true',- help='Compress images before embedding (JPEG quality=85, PNG optimize)')- parser.add_argument('--max-dimension', type=int, default=None,- help='Downscale images exceeding this dimension on either axis (e.g., 2560)')+ parser.add_argument('--compress', dest='compress', action='store_true', default=True,+ help='Compress images before embedding (default)')+ parser.add_argument('--no-compress', dest='compress', action='store_false',+ help='Disable image compression before embedding')+ parser.add_argument('--max-dimension', type=int, default=2560,+ help='Downscale images exceeding this dimension on either axis (default: 2560)')+ parser.add_argument('--image-scale', type=float, default=2.0,+ help='Target image pixels per SVG display pixel (default: 2.0)')args = parser.parse_args()@@ -337,9 +344,17 @@ Aliases (still accepted):'fix_rounded': True,}+ if args.max_dimension < 1:+ safe_print("[ERROR] --max-dimension must be >= 1")+ sys.exit(1)+ if args.image_scale < 1:+ safe_print("[ERROR] --image-scale must be >= 1")+ sys.exit(1)+success = finalize_project(args.project_dir, options, args.dry_run, args.quiet,compress=args.compress,- max_dimension=args.max_dimension)+ max_dimension=args.max_dimension,+ image_scale=args.image_scale)sys.exit(0 if success else 1)diff --git a/skills/ppt-master/scripts/svg_finalize/align_embed_images.py b/skills/ppt-master/scripts/svg_finalize/align_embed_images.pyindex bbea054a..e28ad09b 100644--- a/skills/ppt-master/scripts/svg_finalize/align_embed_images.py+++ b/skills/ppt-master/scripts/svg_finalize/align_embed_images.py@@ -163,6 +163,43 @@ def _normalize_for_save(img: 'PILImage', mime_type: str) -> 'PILImage':return img+def _has_alpha(img: 'PILImage') -> bool:+ """Return whether a PIL image has transparency."""+ if img.mode in ('RGBA', 'LA'):+ return True+ if img.mode == 'P':+ return 'transparency' in getattr(img, 'info', {})+ return False+++def _target_size(+ box_w: float,+ box_h: float,+ *,+ max_dimension: int | None,+ image_scale: float,+) -> tuple[int, int]:+ """Resolve the pixel budget for a rendered SVG image box."""+ target_w = max(1, int(round(box_w * max(image_scale, 1.0))))+ target_h = max(1, int(round(box_h * max(image_scale, 1.0))))+ if max_dimension and max(target_w, target_h) > max_dimension:+ ratio = max_dimension / max(target_w, target_h)+ target_w = max(1, int(round(target_w * ratio)))+ target_h = max(1, int(round(target_h * ratio)))+ return target_w, target_h+++def _downscale_to_target(img: 'PILImage', target_w: int, target_h: int) -> tuple['PILImage', bool]:+ """Downscale without upsampling."""+ width, height = img.size+ ratio = min(target_w / width, target_h / height, 1.0)+ if ratio >= 1.0:+ return img, False+ from PIL import Image+ new_size = (max(1, int(round(width * ratio))), max(1, int(round(height * ratio))))+ return img.resize(new_size, Image.Resampling.LANCZOS), True++def _encode_pil_to_data_uri(img: 'PILImage',src_path: Path,@@ -178,7 +215,10 @@ def _encode_pil_to_data_uri(already-optimized asset. *fallback_bytes* carries the raw on-diskbytes for that path."""- mime_type = get_mime_type(src_path.name, fallback_bytes)+ original_mime_type = get_mime_type(src_path.name, fallback_bytes)+ mime_type = original_mime_type+ if compress and mime_type == 'image/png' and not _has_alpha(img):+ mime_type = 'image/jpeg'pil_format = _PIL_FORMAT_BY_MIME.get(mime_type, 'PNG')# Encode current PIL image@@ -200,7 +240,7 @@ def _encode_pil_to_data_uri(# round-tripping an asset that was already well-compressed inflates it),# fall back to those.chosen = encoded_bytes- if fallback_bytes and len(fallback_bytes) < len(encoded_bytes):+ if fallback_bytes and mime_type == original_mime_type and len(fallback_bytes) < len(encoded_bytes):chosen = fallback_byteschosen = _optimize_image_bytes(@@ -239,6 +279,7 @@ def _process_one_image(*,compress: bool,max_dimension: int | None,+ image_scale: float,verbose: bool,) -> tuple[bool, str | None]:"""Align (slice/meet) and embed a single <image>.@@ -288,6 +329,7 @@ def _process_one_image(final_img: 'PILImage' = imgnew_x, new_y, new_w, new_h = box_x, box_y, box_w, box_htransformed = False # True iff bitmap content changed (crop happened)+ target_box_w, target_box_h = box_w, box_hif not par_attr:# No preserveAspectRatio at all. The previous pipeline's fix-aspect@@ -314,6 +356,16 @@ def _process_one_image(new_y = box_y + off_ynew_w = new_w_calcnew_h = new_h_calc+ target_box_w, target_box_h = new_w, new_h++ target_w, target_h = _target_size(+ target_box_w,+ target_box_h,+ max_dimension=max_dimension,+ image_scale=image_scale,+ )+ final_img, resized = _downscale_to_target(final_img, target_w, target_h)+ transformed = transformed or resized# ------------------------------------------------------------------# Encode and rewrite@@ -372,8 +424,9 @@ def align_and_embed_images_in_svg(*,dry_run: bool = False,verbose: bool = False,- compress: bool = False,- max_dimension: int | None = None,+ compress: bool = True,+ max_dimension: int | None = 2560,+ image_scale: float = 2.0,) -> tuple[int, int]:"""Run the merged align + embed pass on a single SVG file.@@ -412,7 +465,8 @@ def align_and_embed_images_in_svg(ok, err = _process_one_image(image, svg_dir,- compress=compress, max_dimension=max_dimension, verbose=verbose,+ compress=compress, max_dimension=max_dimension,+ image_scale=image_scale, verbose=verbose,)if ok:processed += 1@@ -440,10 +494,14 @@ def build_parser() -> argparse.ArgumentParser:parser.add_argument('svg', type=Path, help='SVG file to process in place')parser.add_argument('-n', '--dry-run', action='store_true')parser.add_argument('-v', '--verbose', action='store_true')- parser.add_argument('--compress', action='store_true',- help='Compress images before embedding')- parser.add_argument('--max-dimension', type=int, default=None,- help='Downscale images larger than this on either axis')+ parser.add_argument('--compress', dest='compress', action='store_true', default=True,+ help='Compress images before embedding (default)')+ parser.add_argument('--no-compress', dest='compress', action='store_false',+ help='Disable image compression')+ parser.add_argument('--max-dimension', type=int, default=2560,+ help='Downscale images larger than this on either axis (default: 2560)')+ parser.add_argument('--image-scale', type=float, default=2.0,+ help='Target pixels per rendered SVG pixel')return parser@@ -455,6 +513,12 @@ def main(argv: list[str] | None = None) -> int:if not args.svg.exists():print(f'Error: file not found: {args.svg}', file=sys.stderr)return 1+ if args.max_dimension < 1:+ print('Error: --max-dimension must be >= 1', file=sys.stderr)+ return 1+ if args.image_scale < 1:+ print('Error: --image-scale must be >= 1', file=sys.stderr)+ return 1proc, err = align_and_embed_images_in_svg(args.svg,@@ -462,6 +526,7 @@ def main(argv: list[str] | None = None) -> int:verbose=args.verbose,compress=args.compress,max_dimension=args.max_dimension,+ image_scale=args.image_scale,)print(f'Processed {proc} image(s), {err} error(s)')return 1 if err else 0diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_context.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_context.pyindex 373cb3b5..e8b6c5a1 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_context.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_context.py@@ -50,6 +50,13 @@ class ConvertContext:# Default-on flag: merge mergeable paragraph blocks into one editable# text frame with multiple <a:p>. Disable it for strict line fidelity.merge_paragraphs: bool = True+ # Native PPTX image optimization. Keeps generated decks compact by+ # downsampling oversized raster assets to their rendered size.+ image_optimize: bool = True+ image_max_dimension: int | None = 2560+ image_sizing: str = 'cap'+ image_scale: float = 2.0+ image_quality: int = 85# Optional per-element conversion diagnostics. Shared by child contexts so# callers can inspect native / skipped / unsupported decisions per slide.trace_events: list[dict[str, Any]] | None = None@@ -153,6 +160,11 @@ class ConvertContext:# anim_targets is intentionally a fresh list on the child;# only the root-level context's list is read by the builder.merge_paragraphs=self.merge_paragraphs,+ image_optimize=self.image_optimize,+ image_max_dimension=self.image_max_dimension,+ image_sizing=self.image_sizing,+ image_scale=self.image_scale,+ image_quality=self.image_quality,trace_events=self.trace_events,)diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.pyindex 53c68faa..4dd97b76 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py@@ -421,6 +421,11 @@ def convert_svg_to_slide_shapes(slide_num: int = 1,verbose: bool = False,merge_paragraphs: bool = True,+ image_optimize: bool = True,+ image_max_dimension: int | None = 2560,+ image_sizing: str = 'cap',+ image_scale: float = 2.0,+ image_quality: int = 85,trace_out: list[dict[str, Any]] | None = None,) -> tuple[str, dict[str, bytes], list[dict[str, str]], list]:"""Convert an SVG file to a complete DrawingML slide XML.@@ -433,6 +438,12 @@ def convert_svg_to_slide_shapes(dy clustered around one base line-height) become a singleeditable text frame with multiple <a:p>. Disable it to preservethe SVG's exact line layout (one textbox per line).+ image_optimize: Downsample oversized raster images for PPTX export.+ image_max_dimension: Maximum optimized image dimension in pixels.+ image_sizing: ``cap`` to only cap source dimensions, ``display`` to+ size from rendered SVG boxes.+ image_scale: Target image pixels per SVG display pixel.+ image_quality: JPEG quality used for opaque optimized rasters.trace_out: Optional list populated with one per-slide trace dictionary.Returns:@@ -495,6 +506,11 @@ def convert_svg_to_slide_shapes(slide_num=slide_num,svg_dir=Path(svg_path).parent,merge_paragraphs=merge_paragraphs,+ image_optimize=image_optimize,+ image_max_dimension=image_max_dimension,+ image_sizing=image_sizing,+ image_scale=image_scale,+ image_quality=image_quality,trace_events=trace_events,)diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.pyindex c1179f61..4fa8cbfd 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py@@ -1808,6 +1808,184 @@ def _read_image_size(data: bytes) -> tuple[int | None, int | None]:return (None, None)+def _parse_preserve_aspect_ratio(par: str | None) -> tuple[str, str]:+ """Parse SVG preserveAspectRatio into ``(align, mode)``."""+ parts = (par or 'xMidYMid meet').strip().split()+ align = parts[0] if parts else 'xMidYMid'+ mode = parts[1] if len(parts) > 1 else 'meet'+ return align, mode+++def _image_has_alpha(img: Any) -> bool:+ """Return whether a PIL image carries useful transparency."""+ if img.mode in ('RGBA', 'LA'):+ return True+ if img.mode == 'P':+ return 'transparency' in getattr(img, 'info', {})+ return False+++def _image_target_size(+ display_w: float,+ display_h: float,+ *,+ max_dimension: int | None,+ scale: float,+) -> tuple[int, int]:+ """Resolve optimized pixel dimensions from rendered SVG dimensions."""+ target_w = max(1, int(round(display_w * max(scale, 1.0))))+ target_h = max(1, int(round(display_h * max(scale, 1.0))))+ if max_dimension and max(target_w, target_h) > max_dimension:+ ratio = max_dimension / max(target_w, target_h)+ target_w = max(1, int(round(target_w * ratio)))+ target_h = max(1, int(round(target_h * ratio)))+ return target_w, target_h+++def _fit_full_image_target(+ img_w: int,+ img_h: int,+ box_w: float,+ box_h: float,+ align: str,+ mode: str,+ *,+ sizing: str,+ max_dimension: int | None,+ scale: float,+) -> tuple[int, int]:+ """Size the full source image; never crop pixels.++ ``cap`` mode only limits oversized source images by maximum dimension.+ ``display`` mode sizes to the rendered SVG box budget.+ """+ if img_w <= 0 or img_h <= 0:+ return (1, 1)++ if sizing == 'cap':+ target_w, target_h = img_w, img_h+ if max_dimension and max(target_w, target_h) > max_dimension:+ ratio = max_dimension / max(target_w, target_h)+ target_w = max(1, int(round(target_w * ratio)))+ target_h = max(1, int(round(target_h * ratio)))+ return target_w, target_h++ target_box_w, target_box_h = _image_target_size(+ box_w,+ box_h,+ max_dimension=None,+ scale=scale,+ )+ img_ratio = img_w / img_h+ box_ratio = box_w / box_h if box_h else img_ratio++ if align != 'none' and mode == 'slice':+ if box_ratio >= img_ratio:+ target_w = target_box_w+ target_h = int(round(target_w / img_ratio))+ else:+ target_h = target_box_h+ target_w = int(round(target_h * img_ratio))+ else:+ ratio = min(target_box_w / img_w, target_box_h / img_h, 1.0)+ target_w = int(round(img_w * ratio))+ target_h = int(round(img_h * ratio))++ target_w = max(1, target_w)+ target_h = max(1, target_h)+ if max_dimension and max(target_w, target_h) > max_dimension:+ ratio = max_dimension / max(target_w, target_h)+ target_w = max(1, int(round(target_w * ratio)))+ target_h = max(1, int(round(target_h * ratio)))+ return target_w, target_h+++def _resize_for_target(img: Any, target_w: int, target_h: int) -> Any:+ """Downscale a PIL image to the target dimensions without upsampling."""+ width, height = img.size+ if target_w >= width and target_h >= height:+ return img+ ratio = min(target_w / width, target_h / height)+ if ratio >= 1.0:+ return img+ try:+ from PIL import Image # type: ignore+ except ImportError:+ return img+ new_size = (max(1, int(round(width * ratio))), max(1, int(round(height * ratio))))+ return img.resize(new_size, Image.Resampling.LANCZOS)+++def _encode_optimized_image(img: Any, *, prefer_jpeg: bool, quality: int) -> tuple[bytes, str] | None:+ """Encode a PIL image for PPTX media."""+ buf = io.BytesIO()+ try:+ if prefer_jpeg and not _image_has_alpha(img):+ if img.mode != 'RGB':+ img = img.convert('RGB')+ img.save(buf, format='JPEG', quality=max(1, min(quality, 100)), optimize=True)+ return buf.getvalue(), 'jpg'+ if img.mode == 'P':+ img = img.convert('RGBA' if _image_has_alpha(img) else 'RGB')+ img.save(buf, format='PNG', optimize=True)+ return buf.getvalue(), 'png'+ except (OSError, ValueError):+ return None+++def _optimize_image_for_pptx(+ elem: ET.Element,+ ctx: ConvertContext,+ img_data: bytes,+ img_format: str,+ box_w: float,+ box_h: float,+) -> tuple[bytes, str]:+ """Optimize full raster image bytes for native PPTX embedding."""+ if not ctx.image_optimize:+ return img_data, img_format+ if img_format.lower() in {'svg', 'emf', 'wmf'}:+ return img_data, img_format++ try:+ from PIL import Image, UnidentifiedImageError # type: ignore+ except ImportError:+ return img_data, img_format++ try:+ img = Image.open(io.BytesIO(img_data))+ img.load()+ except (UnidentifiedImageError, OSError, ValueError):+ return img_data, img_format++ align, mode = _parse_preserve_aspect_ratio(elem.get('preserveAspectRatio'))+ target_w, target_h = _fit_full_image_target(+ img.size[0],+ img.size[1],+ box_w,+ box_h,+ align,+ mode,+ sizing=ctx.image_sizing,+ max_dimension=ctx.image_max_dimension,+ scale=ctx.image_scale,+ )++ original_size = img.size+ img = _resize_for_target(img, target_w, target_h)+ resized = img.size != original_size+ prefer_jpeg = img_format.lower() in {'png', 'jpg', 'jpeg', 'bmp', 'tif', 'tiff'}+ encoded = _encode_optimized_image(img, prefer_jpeg=prefer_jpeg, quality=ctx.image_quality)+ if encoded is None:+ return img_data, img_format++ optimized_data, optimized_format = encoded+ if not resized and len(optimized_data) >= len(img_data):+ return img_data, img_format++ return optimized_data, optimized_format++def _compute_slice_src_rect(img_w: float, img_h: float,box_w: float, box_h: float,@@ -1869,10 +2047,7 @@ def _resolve_image_src_rect(shrinks the picture frame to match image aspect ratio); none mode keepsthe legacy stretch behaviour intentionally."""- par = (elem.get('preserveAspectRatio') or 'xMidYMid meet').strip()- parts = par.split()- align = parts[0] if parts else 'xMidYMid'- mode = parts[1] if len(parts) > 1 else 'meet'+ align, mode = _parse_preserve_aspect_ratio(elem.get('preserveAspectRatio'))if align == 'none' or mode != 'slice':return '' # meet handled by frame fit; none → stretch is correct per SVG spec@@ -1910,10 +2085,7 @@ def _resolve_image_meet_fit(- intrinsic image dimensions cannot be read- frame already matches image ratio (no-op)"""- par = (elem.get('preserveAspectRatio') or 'xMidYMid meet').strip()- parts = par.split()- align = parts[0] if parts else 'xMidYMid'- mode = parts[1] if len(parts) > 1 else 'meet'+ align, mode = _parse_preserve_aspect_ratio(elem.get('preserveAspectRatio'))if align == 'none' or mode == 'slice':return None@@ -1991,6 +2163,10 @@ def convert_image(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:img_format = 'jpg'img_data = img_path.read_bytes()+ img_data, img_format = _optimize_image_for_pptx(+ elem, ctx, img_data, img_format, w, h,+ )+img_idx = len(ctx.media_files) + 1img_filename = f's{ctx.slide_num}_img{img_idx}.{img_format}'ctx.media_files[img_filename] = img_data@@ -2007,10 +2183,9 @@ 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)- # Resolve preserveAspectRatio="<align> slice" → DrawingML <a:srcRect>.- # This keeps the original image intact in the .pptx and lets users- # re-crop or reset the picture in PowerPoint, instead of permanently- # baking the crop into the embedded asset.+ # Resolve preserveAspectRatio="<align> slice" as DrawingML crop metadata.+ # Image optimization only downscales the full source image; it never crops+ # pixels out of the embedded media.src_rect_xml = _resolve_image_src_rect(elem, img_data, w, h)# Resolve preserveAspectRatio="<align> meet" by shrinking the picture@@ -2215,6 +2390,10 @@ def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nimg_format = 'jpg'img_data = img_path.read_bytes()+ img_data, img_format = _optimize_image_for_pptx(+ image_elem, ctx, img_data, img_format, w, h,+ )+img_idx = len(ctx.media_files) + 1img_filename = f's{ctx.slide_num}_img{img_idx}.{img_format}'ctx.media_files[img_filename] = img_datadiff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.pyindex e3870096..2a40167f 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py@@ -624,6 +624,11 @@ def create_pptx_with_native_svg(cache_dir: Path | None = None,workers: int | None = None,merge_paragraphs: bool = True,+ image_optimize: bool = True,+ image_max_dimension: int | None = 2560,+ image_sizing: str = 'cap',+ image_scale: float = 2.0,+ image_quality: int = 85,conversion_trace_path: Path | None = None,doc_metadata: dict[str, Any] | None = None,) -> bool:@@ -653,6 +658,12 @@ def create_pptx_with_native_svg(narration_audio: Optional dict mapping SVG stem to narration audio file.use_narration_timings: Whether to set slide auto-advance from audio duration.narration_padding: Extra seconds added after each narration before advancing.+ image_optimize: Whether native export downscales oversized raster images.+ image_max_dimension: Maximum optimized image dimension in pixels.+ image_sizing: ``cap`` only limits source dimensions; ``display`` sizes+ from rendered SVG boxes.+ image_scale: Target image pixels per SVG display pixel.+ image_quality: JPEG quality used for opaque optimized rasters.conversion_trace_path: Optional JSON path for native conversion diagnostics.Returns:@@ -700,6 +711,20 @@ def create_pptx_with_native_svg(print(f" SVG file count: {len(svg_files)}")if use_native_shapes:print(f" Mode: Native DrawingML shapes (directly editable)")+ if image_optimize:+ if image_sizing == 'display':+ image_mode = (+ f"display scale {image_scale:g}, "+ f"max {image_max_dimension or 'unlimited'} px"+ )+ else:+ image_mode = f"cap max {image_max_dimension or 'unlimited'} px"+ print(+ " Image optimization: Enabled "+ f"({image_mode}, JPEG q{image_quality})"+ )+ else:+ print(" Image optimization: Disabled")elif use_compat_mode:print(f" Compatibility mode: Enabled (PNG + SVG dual format)")print(f" PNG renderer: {renderer_name} {renderer_status}")@@ -779,6 +804,11 @@ def create_pptx_with_native_svg(convert_svg_to_slide_shapes(svg_path, slide_num=slide_num, verbose=verbose,merge_paragraphs=merge_paragraphs,+ image_optimize=image_optimize,+ image_max_dimension=image_max_dimension,+ image_sizing=image_sizing,+ image_scale=image_scale,+ image_quality=image_quality,trace_out=conversion_trace,))diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.pyindex ea2cf27f..af51bd48 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py@@ -189,6 +189,16 @@ Recorded narration:'canonical output; live preview already provides the SVG visual reference. ''Note: the svg_output/ source snapshot is always written to backup/<ts>/ ''regardless of this flag.')+ parser.add_argument('--no-image-optimize', action='store_true',+ help='Disable native PPTX raster image optimization; embeds original image bytes.')+ parser.add_argument('--image-max-dimension', type=int, default=2560,+ help='Maximum optimized raster image dimension in pixels (default: 2560).')+ parser.add_argument('--image-sizing', choices=['cap', 'display'], default='cap',+ help='Raster sizing mode: cap only limits source dimensions; display sizes from the SVG rendered box (default: cap).')+ parser.add_argument('--image-scale', type=float, default=2.0,+ help='Target optimized image pixels per SVG display pixel when --image-sizing=display (default: 2.0).')+ parser.add_argument('--image-quality', type=int, default=85,+ help='JPEG quality for optimized opaque raster images, 1-100 (default: 85).')def non_negative_float(value: str) -> float:try:@@ -262,6 +272,15 @@ Recorded narration:if not project_path.exists():print(f"Error: Path does not exist: {project_path}")return 1+ if args.image_max_dimension < 1:+ print("Error: --image-max-dimension must be >= 1", file=sys.stderr)+ return 1+ if args.image_scale < 1:+ print("Error: --image-scale must be >= 1", file=sys.stderr)+ return 1+ if not 1 <= args.image_quality <= 100:+ print("Error: --image-quality must be between 1 and 100", file=sys.stderr)+ return 1try:project_info = get_project_info(str(project_path))@@ -567,6 +586,11 @@ Recorded narration:cache_dir=cache_dir,workers=args.workers,merge_paragraphs=args.merge_paragraphs,+ image_optimize=not args.no_image_optimize,+ image_max_dimension=args.image_max_dimension,+ image_sizing=args.image_sizing,+ image_scale=args.image_scale,+ image_quality=args.image_quality,)success = True