Skip to content

Export: animated GIF of the deck (Export… dialog, CLI, MCP) (#171) - #177

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Mathiasko:feat/export-animated-gif
Oct 14, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Mathiasko:feat/export-animated-gif

Conversation

@Mathiasko

Copy link
Copy Markdown
Contributor

Fixes #171.

Problem

There was no way to turn a presentation into an animated GIF: docs/file-format-parity.md listed "Animated GIF of the deck" as export: no, docs/gaps.md had it under "No video or animated GIF export", and the checklist row was M. PowerPoint's Export ▸ Create an Animated GIF is a common way to share a short deck.

What changed

  • file.export writes an animated GIF (format gif, or a .gif path): one frame per slide from the slide renderer, shown for secondsPerSlide, through the image crate's GIF encoder (already a dependency; no new crates). Each frame gets its own 256-colour palette: exact when the slide has 256 colours or fewer, NeuQuant otherwise. Slides are composited onto white.
  • Options: width (small 640, medium 960 (default), large 1280, extraLarge 1920, or 16–3840 px; the height follows the slide's aspect ratio, no side above 3840), secondsPerSlide (0.1–600, default 5), loop (forever by default, or once), slides (indices in play order) and includeHidden (hidden slides are skipped by default).
  • Never crash: wrong types, out-of-range values, NaN and infinities are parameter errors; at most 500 frames and 200 million pixels in total, checked before anything is rendered.
  • The Export… dialog gets "Animated GIF (.gif)" with Size, Seconds per slide, From/To slide, Loop forever and Include hidden slides; an invalid range or value keeps the dialog open with a message. The web build downloads the GIF.
  • CLI: deckcraft-cli convert IN OUT.gif, deckcraft-cli run --export OUT.gif --export-params '{"width":"large","secondsPerSlide":3}'; usage lists the formats and GIF options.
  • MCP: the export tool lists gif and its options (width, secondsPerSlide, loop; slides and includeHidden now apply to PDF and GIF), as in Issue #44: MCP: the export tool lists PDF and its layout options #65.
  • Docs: file-format parity (GIF row: yes), gaps (video export remains), parity checklist row M → P (P2 36% → 37%, overall breadth stays 79%), control protocol, MCP, README, ROADMAP progress log.

Tests

  • Engine: a generated 4-slide deck with distinct backgrounds and one hidden slide → decode the GIF: 3 frames, 320×180, 1.5 s delay, loop forever, frame colours in slide order; presets, a reversed range, include hidden, play once, 5 s default; hostile values (0, 15, 3841, -5, 1e308, 640.5, "huge", NaN, ±inf, empty and out-of-range slide lists, >500 frames…) are errors with nothing written; tall slides, the pixel budget and a broken slide size.
  • MCP: the export tool lists gif and its options; what it lists is accepted; width: 0 is a tool error.
  • CLI (new test module): run --export --export-params and convert write GIFs; bad options are errors.
  • UI (egui_kittest): Export… ▸ Animated GIF ▸ untick Loop forever ▸ an out-of-range slide range keeps the dialog open ▸ a valid range exports a 960 px GIF that plays once.

Verified on macOS arm64

  • CRAFT_FONTS_DIR=<craft-fonts at ci.yml's CRAFT_FONTS_REF> cargo xtask ci passes (fmt, clippy -D warnings, 509 tests, assets, layers, wasm). The last edit after that run only reworded comments and docs; cargo fmt --check passes on it.
  • Exported the sample deck with one hidden slide from the CLI (7 frames, 960×540, 2 s, looping) and looked at the frames as PNGs: right slides, right order, gradients and diagrams clean.
  • Opened Export… ▸ Animated GIF in the app and exported through it.

Notes

  • The app has no native menu bar yet (docs/ui-parity.md), so the Export… dialog is reached from the Command palette (⌘F). The palette lists two entries labelled "Export…": the UI one that opens the dialog, and the engine file.export, which needs a path and fails with "missing path" when run from the palette. That duplicate already exists on main; not changed here.
  • The size names are PowerPoint's wording; the pixel values are our own.

Not in this PR

  • Animating transitions and build animations between frames, or one frame per click step (tracked with MP4/MOV video export in gaps.md).
  • MP4/MOV video export.
  • A transparent background option.

🤖 Generated with Claude Code

…d#171)

There was no way to turn a presentation into an animated GIF. file.export now writes one: format
`gif` (or a .gif path), one frame per slide drawn by the slide renderer and shown for
secondsPerSlide, encoded with the `image` crate's GIF encoder (already a dependency, no new
crates) with a 256-colour palette per frame: exact when a slide has 256 colours or fewer,
NeuQuant otherwise. Slides are composited onto white.

Options: width (small 640, medium 960 (default), large 1280, extraLarge 1920, or 16-3840 px; the
height follows the slide's aspect ratio, no side over 3840), secondsPerSlide (0.1-600, default 5,
written in GIF hundredths), loop (forever by default, or once: no NETSCAPE2.0 block), slides (a
list of indices, in play order) and includeHidden (hidden slides are skipped by default).
Out-of-range or wrongly typed values, NaN and infinities are BadParams errors, never panics; at
most 500 frames and 200 million pixels in total, checked before anything is rendered.

- Engine: crates/engine/src/gif_export.rs (options, frame list, size, encoder);
  cmd::file::gif_bytes, save_bytes("gif"), format_for_path(".gif").
- UI: the Export… dialog (Command palette; the app has no File menu yet) gets "Animated GIF (.gif)" with Size, Seconds per slide, From/To slide,
  Loop forever and Include hidden slides; an invalid range or value keeps the dialog open with a
  message. The web build downloads the bytes (image/gif).
- CLI: convert IN OUT.gif, run --export OUT.gif --export-params JSON; usage lists the format and
  options.
- MCP: the export tool lists gif and width/secondsPerSlide/loop (slides and includeHidden now
  apply to PDF and GIF).
- Docs: file-format parity GIF row, gaps (video export remains), parity checklist row M -> P
  (P2 breadth 36% -> 37%, overall 79%), control protocol, MCP, README, ROADMAP progress log.

Transitions and build animations are not animated in the GIF (tracked with video export).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon

echelon commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thank you for this contribution, @Mathiasko! It has landed on main and will ship in the next DeckCraft release.

If you haven't already, please come join us on Discord: https://discord.gg/artcraft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export the deck as an animated GIF (File ▸ Export ▸ Create an Animated GIF)

3 participants