Home

Awesome

gif-extract-frames

Extracts frames from GIFs including inter-frame coalescing.

NPM Build Status JavaScript Style Guide

Why?

Some GIFs store delta information between frames instead of storing complete frames. Here's an example:


Original gif (source).

Input gif bubbles


5 extracted frames without coalescing.

Example without coalescing


5 extracted frames with coalescing.

Example without coalescing


Install

This module requires node >= 8.

npm install --save gif-extract-frames

Usage

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])

API

extractFrames(opts)

Returns: Promise<ndarray>

Returns a modified version of the ndarray returned by get-pixels.

opts.input

Type: String Required

Path to a GIF file.

opts.output

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.

opts.coalesce

Type: Boolean Default: true

Whether or not to perform inter-frame coalescing.

Related

License

MIT © Travis Fischer

Support my OSS work by <a href="https://twitter.com/transitive_bs">following me on twitter <img src="https://storage.googleapis.com/saasify-assets/twitter-logo.svg" alt="twitter" height="24px" align="center"></a>