https://github.com/richienb/decode-gif
Decode the frames of a gif.
https://github.com/richienb/decode-gif
Last synced: 9 months ago
JSON representation
Decode the frames of a gif.
- Host: GitHub
- URL: https://github.com/richienb/decode-gif
- Owner: Richienb
- License: mit
- Created: 2020-05-11T06:07:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-14T02:07:59.000Z (over 3 years ago)
- Last Synced: 2025-04-14T06:38:05.636Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.42 MB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# decode-gif [](https://travis-ci.com/Richienb/decode-gif)
Decode the frames of a gif.
[](https://npmjs.com/package/decode-gif)
## Install
```sh
npm install decode-gif
```
## Usage
```js
const fs = require("fs");
const decodeGif = require("decode-gif");
decodeGif(fs.readFileSync("unicorn.gif"));
/*
{
width: 220,
height: 165,
frames: [
{ timeCode: 0, data: [Uint8ClampedArray] },
{ timeCode: 10, data: [Uint8ClampedArray] },
...
]
}
*/
```
## API
### decodeGif(data)
#### data
Type: `array-like`
The gif data. Can be anything array-like such as a `Buffer`, `Array` or `Uint8Array`.
#### Return value
##### width
Type: `number`
The width of the gif.
##### height
Type: `number`
The height of the gif.
##### frames
An array of each frame of the gif.
##### frame.timeCode
The time code in milliseconds that the frame appears at.
##### frame.data
The frame data as a `Uint8ClampedArray`.