gif2sprite

0.0.2 • Public • Published

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.

Package Sidebar

Install

npm i gif2sprite

Weekly Downloads

11

Version

0.0.2

License

MIT

Unpacked Size

14.8 kB

Total Files

8

Last publish

Collaborators

  • latpaw