Extracts frames from GIFs including inter-frame coalescing.
Some GIFs store delta information between frames instead of storing complete frames. Here"s an example:
Original gif (source).
5 extracted frames without coalescing.
5 extracted frames with coalescing.
This module requires node >= 8
.
npm install --save gif-extract-frames
const extractFrames = require("gif-extract-frames")
const results = await extractFrames({
input: "./media/bubbles.gif",
output: "frame-%d.png"
})
console.log("number of frames", results.shape[0])
Returns: Promise<ndarray>
Returns a modified version of the ndarray returned by get-pixels.
Type: String
Required
Path to a GIF file.
Type: String
Example: "output/frame-%d.png"
Optional frame pattern if you want to write each frame to disk. Should contain a %d
that will be replaced with the frame number (starting at 0).
The resulting ndarray will be returned whether or not an output
is given.
Type: Boolean
Default: true
Whether or not to perform inter-frame coalescing.
- gifsicle - GIF manipulation library capable of exploding gifs, but AFAIK does not support frame coalescing when exporting frames.
- gif-explode - Alternative which uses gifsicle but does not support frame coalescing.
- omggif - JavaScript GIF encoder & decoder used under the hood.
- ffmpeg-extract-frames - Analogous module for extracting frames from video files.
MIT © Travis Fischer
Support my OSS work by following me on twitter