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(images): pass animated images through untouched in all three optimize paths

颀立 沈6169d5eef544
diff --git a/skills/ppt-master/scripts/svg_finalize/align_embed_images.py b/skills/ppt-master/scripts/svg_finalize/align_embed_images.py
index e28ad09b..c53c9285 100644
--- a/skills/ppt-master/scripts/svg_finalize/align_embed_images.py
+++ b/skills/ppt-master/scripts/svg_finalize/align_embed_images.py
@@ -313,6 +313,26 @@ def _process_one_image(
if img is None:
return False, 'PIL open failed'
+ # Multi-frame images (animated GIF / WebP / APNG): every PIL transform
+ # and re-save below operates on frame 0 only, silently flattening the
+ # animation — and the "original bytes are smaller" fallback never fires
+ # because one frame is always smaller than all frames. Embed the raw
+ # bytes untouched and keep the geometry attributes (including
+ # preserveAspectRatio, which the native converter maps to srcRect
+ # non-destructively). Animated assets skip re-encode, resize, and the
+ # size cap.
+ if getattr(img, 'is_animated', False):
+ mime_type = get_mime_type(img_path.name, raw_bytes)
+ b64 = base64.b64encode(raw_bytes).decode('ascii')
+ _set_href(image, f'data:{mime_type};base64,{b64}')
+ if max_dimension and max(img.size) > max_dimension:
+ print(f' [WARN] {img_path.name}: animated image kept as-is '
+ f'({img.size[0]}x{img.size[1]} exceeds max dimension '
+ f'{max_dimension}px); animations are exempt from size limits')
+ if verbose:
+ print(f' [OK] {img_path.name} (animated, embedded as-is)')
+ return True, None
+
box_x = _parse_float(image.get('x'))
box_y = _parse_float(image.get('y'))
box_w = _parse_float(image.get('width'))
diff --git a/skills/ppt-master/scripts/svg_finalize/embed_images.py b/skills/ppt-master/scripts/svg_finalize/embed_images.py
index 7cfd504c..08be8b7c 100644
--- a/skills/ppt-master/scripts/svg_finalize/embed_images.py
+++ b/skills/ppt-master/scripts/svg_finalize/embed_images.py
@@ -84,6 +84,19 @@ def _optimize_image_bytes(img_bytes: bytes, mime_type: str,
except Exception:
return img_bytes
+ # Multi-frame images (animated GIF / WebP / APNG): resize/re-save below
+ # keeps frame 0 only, silently flattening the animation. Pass the
+ # original bytes through — animations are exempt from compression and
+ # the size cap.
+ if getattr(img, 'is_animated', False):
+ if max_dimension:
+ w, h = img.size
+ if w > max_dimension or h > max_dimension:
+ print(f" [WARN] Animated image kept as-is ({w}x{h} exceeds "
+ f"max dimension {max_dimension}px); animations are "
+ f"exempt from size limits")
+ return img_bytes
+
changed = False
# Downscale if exceeding max_dimension
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
index 4fa8cbfd..2fa2a570 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
@@ -1958,6 +1958,14 @@ def _optimize_image_for_pptx(
except (UnidentifiedImageError, OSError, ValueError):
return img_data, img_format
+ # Multi-frame images (animated GIF / WebP / APNG): resize/re-encode
+ # below keeps frame 0 only, flattening the animation in the exported
+ # PPTX. Pass the original bytes through — animations are exempt from
+ # optimization and the size cap (before this optimizer existed, the
+ # native path embedded raster bytes verbatim and animations survived).
+ if getattr(img, 'is_animated', False):
+ 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],