gif-info
gif-info is currently only available as a CommonJS module to use with Browserify.
npm install gif-info
A JavaScript library for reading information from animated GIFs
How to use
First you need to get the gif file into memory as ArrayBuffer
. This is out of scope of gif-info, but you could for example load it via xhr with responseType
set to arraybuffer
. Then simply pass the data to the function exported by gif-info.
var xhr = ;var gifInfo = ; var options = url: 'fail.gif' method: 'GET' responseType: 'arraybuffer'; ;
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.
- 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 (50fps)
- 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
- identifier (string) - Image identifier (frame number or embeded string).
- 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.
- text (string) - frame text. aka Plain Text Extension.
- comments ([comments]) - Array of comment strings.
- disposal (int) - Disposal method. (0-7). See this for more details.
Example
Resources
- What's In A GIF - Bit by Byte - Hands down the best write up on GIFs I've found.
- GIF98 - GIF98 RFC.
- Animated GIF Frame Rate by Browser - An awesome breakdown of how each browser renders animated GIFs. Thanks to Jeremiah Johnson for doing the hard work.
- GIF Format - GIF blocks.
- Hexfiend - Awesome open source HEX editor (OSX)
License
Licence: Do What The Fuck You Want To Public License
Changelog
1.0.1 (2016-04-12)
- Fixed width/height being switched.