gify-parse

An API for parsing information on (animated) GIF files.

gify-parse

A Node.JS module for parsing information on (animated) GIF files.

gify-parse is a fork of gify by rfrench that is intended to encapsulate the logic into a Node.JS module and to provide a command-line interface.

Install with the Node.JS package manager npm:

$ npm install gify-parse

or

Install via git clone:

$ git clone git://github.com/jonashavers/node-gify-parse.git
$ cd node-gify-parse
$ npm install

Usage inside your Node.JS modules:

var fs = require('fs');
var gifyParse = require('gify-parse');

var buffer = fs.readFileSync('test.gif');
var gifInfo = gifyParse.getInfo(buffer);

console.log(gifInfo);

Usage of the CLI (command-line interface):

$ gifyParse <file> [option]

e.g.

$ gifyParse test.gif
$ gifyParse test.gif -p duration
$ gifyParse test.gif -p images.0.delay

The examples above parse the file test.gif and print out the GIF file's information on the console.

gify-parse requires

  • isAnimated(sourceArrayBuffer) (bool)
  • getInfo(sourceArrayBuffer) (gifInfo)
  • valid (bool) - Determines if the GIF is valid.
  • animated (bool) - Determines if the GIF is animated.
  • globalPalette (bool) - Determines if the GIF has a global color palette.
  • globalPaletteSize (int) - Size of the global color palette.
  • height (int) - Canvas height.
  • width (int) - Canvas width.
  • loopCount (int) - Total number of times the GIF will loop. 0 represents infitine.
  • images ([images]) - Array of images contained in the GIF.
  • isBrowserDuration (bool) - If any of the delay times are lower than the minimum value, this value will be set to true.
  • duration (int) - Actual duration calculated from the delay time for each image. If isBrowserDuration is false, you should use this value.
  • durationIE (int) - Duration for Internet Explorer (16fps)
  • durationSafari (int) - Duration for Safari in milliseconds (16fps)
  • durationFirefox (int) - Duration for Firefox in milliseconds (50fps)
  • durationChrome (int) - Duration for Chrome in milliseconds (50fps)
  • durationOpera (int) - Duration for Opera in milliseconds (50fps)
  • top (int) - Image top position (Y).
  • left (int) - Image left position (X).
  • height (int) - Image height.
  • width (int) - Image width.
  • localPalette (bool) - Image has a local color palette.
  • localPaletteSize (int) - Size of the local color palette.
  • interlace (bool) - Image is/is not interlaced.
  • delay (int) - Delay time in milliseconds.
  • disposal (int) - Disposal method. (0-7). See this for more details.
{
  "valid": true,
  "globalPalette": true,
  "globalPaletteSize": 256,
  "loopCount": 0,
  "height": 1610,
  "width": 899,
  "animated": true,
  "images": [
    {
      "localPalette": false,
      "localPaletteSize": 0,
      "interlace": false,
      "left": 0,
      "top": 0,
      "width": 1610,
      "height": 899,
      "delay": 350,
      "disposal": 0
    },
    {
      "localPalette": true,
      "localPaletteSize": 256,
      "interlace": false,
      "left": 0,
      "top": 0,
      "width": 1610,
      "height": 899,
      "delay": 350,
      "disposal": 0
    },
    {
      "localPalette": true,
      "localPaletteSize": 256,
      "interlace": false,
      "left": 0,
      "top": 0,
      "width": 1610,
      "height": 899,
      "delay": 350,
      "disposal": 0
    }
  ],
  "isBrowserDuration": false,
  "duration": 2800,
  "durationIE": 2800,
  "durationSafari": 2800,
  "durationFirefox": 2800,
  "durationChrome": 2800,
  "durationOpera": 2800
}

Licence: MIT