Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cesiumlabs/gif
GIF Encoder/Decoder for Canvacord
https://github.com/cesiumlabs/gif
canvacord gif-extract-frames gif-frames gifdecoder gifencoder
Last synced: 27 days ago
JSON representation
GIF Encoder/Decoder for Canvacord
- Host: GitHub
- URL: https://github.com/cesiumlabs/gif
- Owner: CesiumLabs
- Created: 2021-05-17T12:05:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-04T11:34:37.000Z (over 3 years ago)
- Last Synced: 2024-11-18T11:06:56.813Z (about 1 month ago)
- Topics: canvacord, gif-extract-frames, gif-frames, gifdecoder, gifencoder
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@canvacord/gif
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @canvacord/gif
GIF Encoder and Decoder for **[Canvacord](https://npmjs.com/package/canvacord)**.# Installation
```sh
$ npm install --save @canvacord/gif// or
$ yarn add @canvacord/gif
```# Examples
## Decoding GIF```js
// es6
import { Decoder } from '@canvacord/gif';
import { readFileSync, createWriteStream } from 'fs';// cjs
const { Decoder } = require('@canvacord/gif');
const { readFileSync, createWriteStream } = require('fs');const source = readFileSync('./img.gif');
const decoder = new Decoder(source);
const rawFrames = decoder.decode();// log raw frames data
console.log(rawFrames);// get png image of each frame
const pngFrames = decoder.toPNG(rawFrames);for (let i = 0; i < pngFrames.length; i++) {
const frame = pngFrames[i];
frame.pipe(createWriteStream(`./frame_${i}.png`));
}
```## Encoding raw frame to GIF
```js
// es6
import { Decoder, Encoder } from '@canvacord/gif';
import { readFileSync, createWriteStream } from 'fs';// cjs
const { Decoder, Encoder } = require('@canvacord/gif');
const { readFileSync, createWriteStream } = require('fs');const source = readFileSync('./img.gif');
const decoder = new Decoder(source);
const rawFrames = decoder.decode();// encode each frames into gif
for (let i = 0; i < rawFrames.length; i++) {
const frame = new Encoder(rawFrames[i]).encode();
frame.pipe(createWriteStream(`./frame_${i}.gif`));
}
```