๐ผ๏ธ svg-animation-convert
Convert animated SVGs to high-quality transparent GIF, APNG, MOV, or WEBM โ frame-accurate, browser-rendered.
Powered by Puppeteer + FFmpeg. MIT Licensed.
โจ Features
- โ
Converts animated SVGs (SMIL,
<animate>
, etc.)
- โ
Uses a real browser for accurate rendering
- โ
Supports transparent backgrounds
- โ
Outputs:
.gif
, .apng
, .mov
, .webm
- โ
Infers viewport size and animation duration from SVG
- โ
Fully configurable via CLI
โ๏ธ Requirements
- FFmpeg installed and available in
$PATH
- Node.js โฅ 18
- Bun or npm
๐ฆ Installation
No install needed โ use with bunx
or npx
:
bunx svg-animation-convert --input=animate.svg --output=out.apng
npx svg-animation-convert --input=animate.svg --output=out.apng
๐ Usage
bunx svg-animation-convert --input=animate.svg --output=out.gif [options]
Required:
--input=...
โ Path to animated SVG
--output=...
โ Output file path (must end in .gif
, .apng
, .mov
, or .webm
)
Optional:
--duration | Duration in ms (inferred from SVG if omitted) | โ |
--fps | Frames per second | 24 |
--loop | Looping (-1 once, 0 infinite, N loops) | 0 |
--frames | Temp frame directory | frames |
๐ Loop Behavior
-1 | Play once | -loop -1 | -plays 1 |
0 | Loop forever | -loop 0 | -plays -1 |
N > 0 | Loop N times | -loop N | -plays N+1 |
๐ Example
bunx svg-animation-convert \
--input=animate.svg \
--output=out.apng \
--fps=30 \
--loop=0
This:
- Loads
animate.svg
in a headless browser
- Renders each frame at 30 FPS
- Outputs a transparent APNG
- Loops the animation forever
๐งช Notes
- Only supports SMIL-based animations (
<animate>
, <set>
, etc.)
- Does not evaluate JavaScript-driven SVG animations
- Resolution is auto-detected from
viewBox
, width
, or height
๐ License
MIT โ ยฉ Almog Baku