gify-parse
A Node.js module for parsing information on (animated) GIF files.
Notes
gify-parse is just 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.
Installation
Install via npm registry:
$ 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
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.
Requirements
gify-parse requires
Methods
isAnimated (sourceArrayBuffer) (bool)
getInfo (sourceArrayBuffer) (gifInfo)
info Properties
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.
globalPaletteColorsRGB ([r,g,b]) - An array of objects containing the R, G, B values of the color palette. (Beppe )
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)
image Properties
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.
Example
{ v a l i d : true ,
g l o b a l P a l e t t e : true ,
g l o b a l P a l e t t e S i z e : 256 ,
g l o b a l P a l e t t e C o l o r s R G B :
[ { r : 142 , g : 44 , b : 14 } ,
{ r : 109 , g : 32 , b : 15 } ,
{ r : 143 , g : 37 , b : 16 } ,
{ r : 150 , g : 53 , b : 17 } ,
{ r : 56 , g : 21 , b : 1 } ,
{ r : 136 , g : 41 , b : 14 } ,
{ r : 59 , g : 14 , b : 0 } ,
{ r : 140 , g : 42 , b : 10 } ,
{ r : 120 , g : 68 , b : 37 } ,
{ r : 120 , g : 56 , b : 36 } ,
{ r : 102 , g : 51 , b : 21 } ,
{ r : 103 , g : 54 , b : 35 } ,
{ r : 121 , g : 100 , b : 75 } ,
{ r : 154 , g : 115 , b : 87 } ,
{ r : 86 , g : 51 , b : 21 } ,
{ r : 69 , g : 20 , b : 3 } ,
{ r : 177 , g : 139 , b : 145 } ,
{ r : 119 , g : 72 , b : 50 } ,
{ r : 102 , g : 69 , b : 39 } ,
{ r : 86 , g : 38 , b : 19 } ,
{ r : 137 , g : 99 , b : 72 } ,
{ r : 206 , g : 77 , b : 80 } ,
{ r : 165 , g : 115 , b : 87 } ,
{ r : 172 , g : 52 , b : 42 } ,
{ r : 121 , g : 84 , b : 55 } ,
{ r : 220 , g : 138 , b : 103 } ,
{ r : 86 , g : 36 , b : 5 } ,
{ r : 54 , g : 18 , b : 1 } ,
{ r : 135 , g : 89 , b : 68 } ,
{ r : 119 , g : 88 , b : 68 } ,
{ r : 135 , g : 69 , b : 52 } ,
{ r : 157 , g : 120 , b : 140 } ,
{ r : 72 , g : 36 , b : 19 } ,
{ r : 71 , g : 35 , b : 5 } ,
{ r : 102 , g : 39 , b : 19 } ,
{ r : 137 , g : 104 , b : 83 } ,
{ r : 209 , g : 110 , b : 77 } ,
{ r : 151 , g : 106 , b : 84 } ,
{ r : 135 , g : 54 , b : 37 } ,
{ r : 211 , g : 181 , b : 210 } ,
{ r : 174 , g : 133 , b : 114 } ,
{ r : 104 , g : 71 , b : 51 } ,
{ r : 101 , g : 36 , b : 5 } ,
{ r : 107 , g : 21 , b : 4 } ,
{ r : 210 , g : 107 , b : 109 } ,
{ r : 168 , g : 71 , b : 52 } ,
{ r : 254 , g : 245 , b : 254 } ,
{ r : 85 , g : 36 , b : 35 } ,
{ r : 155 , g : 119 , b : 100 } ,
{ r : 86 , g : 22 , b : 2 } ,
{ r : 206 , g : 82 , b : 54 } ,
{ r : 135 , g : 68 , b : 36 } ,
{ r : 182 , g : 150 , b : 167 } ,
{ r : 209 , g : 85 , b : 104 } ,
{ r : 88 , g : 53 , b : 35 } ,
{ r : 134 , g : 86 , b : 55 } ,
{ r : 175 , g : 103 , b : 49 } ,
{ r : 207 , g : 171 , b : 182 } ,
{ r : 229 , g : 110 , b : 136 } ,
{ r : 152 , g : 104 , b : 72 } ,
{ r : 71 , g : 22 , b : 18 } ,
{ r : 153 , g : 69 , b : 52 } ,
{ r : 136 , g : 53 , b : 21 } ,
{ r : 152 , g : 54 , b : 37 } ,
{ r : 204 , g : 145 , b : 138 } ,
{ r : 119 , g : 38 , b : 19 } ,
{ r : 115 , g : 49 , b : 7 } ,
{ r : 242 , g : 216 , b : 243 } ,
{ r : 152 , g : 69 , b : 35 } ,
{ r : 109 , g : 53 , b : 72 } ,
{ r : 118 , g : 37 , b : 6 } ,
{ r : 169 , g : 56 , b : 65 } ,
{ r : 107 , g : 90 , b : 67 } ,
{ r : 136 , g : 37 , b : 19 } ,
{ r : 53 , g : 7 , b : 0 } ,
{ r : 239 , g : 103 , b : 113 } ,
{ r : 103 , g : 53 , b : 52 } ,
{ r : 170 , g : 46 , b : 22 } ,
{ r : 56 , g : 34 , b : 6 } ,
{ r : 182 , g : 86 , b : 103 } ,
{ r : 152 , g : 52 , b : 21 } ,
{ r : 137 , g : 104 , b : 102 } ,
{ r : 152 , g : 86 , b : 70 } ,
{ r : 152 , g : 119 , b : 119 } ,
{ r : 184 , g : 161 , b : 208 } ,
{ r : 170 , g : 85 , b : 69 } ,
{ r : 152 , g : 100 , b : 44 } ,
{ r : 102 , g : 50 , b : 6 } ,
{ r : 151 , g : 38 , b : 21 } ,
{ r : 118 , g : 55 , b : 53 } ,
{ r : 244 , g : 178 , b : 139 } ,
{ r : 152 , g : 85 , b : 53 } ,
{ r : 254 , g : 206 , b : 168 } ,
{ r : 120 , g : 87 , b : 85 } ,
{ r : 139 , g : 82 , b : 109 } ,
{ r : 152 , g : 86 , b : 35 } ,
{ r : 151 , g : 105 , b : 102 } ,
{ r : 233 , g : 107 , b : 81 } ,
{ r : 73 , g : 50 , b : 19 } ,
{ r : 101 , g : 39 , b : 36 } ,
. . . 156 m o r e i t e m s ] ,
l o o p C o u n t : 0 ,
h e i g h t : 400 ,
w i d t h : 720 ,
a n i m a t e d : true ,
i m a g e s :
[ { i d e n t i f i e r : ' 0 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 1 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 2 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 3 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 4 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 5 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 6 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 7 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 8 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 9 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 10 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 11 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 12 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 13 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 14 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 15 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 16 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 17 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 18 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 19 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 20 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 21 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 22 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 23 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ,
{ i d e n t i f i e r : ' 24 ' ,
l o c a l P a l e t t e : false ,
l o c a l P a l e t t e S i z e : 0 ,
i n t e r l a c e : false ,
c o m m e n t s : [ ] ,
t e x t : ' ' ,
l e f t : 0 ,
t o p : 0 ,
w i d t h : 720 ,
h e i g h t : 400 ,
d e l a y : 40 ,
d i s p o s a l : 1 } ] ,
i s B r o w s e r D u r a t i o n : true ,
d u r a t i o n : 1000 ,
d u r a t i o n I E : 2500 ,
d u r a t i o n S a f a r i : 1000 ,
d u r a t i o n F i r e f o x : 1000 ,
d u r a t i o n C h r o m e : 1000 ,
d u r a t i o n O p e r a : 1000 }
Resources
License
Licence: MIT