gif2sprite
v0.0.2
Published
Extracts frames from a GIF including inter-frame coalescing. from gif-extract-frames.
Downloads
3
Readme
Install
This module requires node >= 8
.
Usage
const extractFrames = require('../index.js');
const fs = require('fs');
async function extract() {
console.log('extract start');
const buffer = fs.readFileSync('./crocodile.gif');
const results = await extractFrames({
input: buffer,
type: 'image/gif', // type is required if input is buffer
// output: 'frame.png', // will be buffer if no output
merge: true, // gif can merge into one sprite
callback: () => {
console.log('done!')
}
});
console.log(results);
}
extract();
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.type
Type: String
requried when input is a buffer value: 'image/gif' etc
opts.merge
Type: String
merge all frames into one sprite png when merge === true
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.