gifencoder
Streaming server-side animated (and non-animated) gif generation for node.js
Installation
This module is installed via npm:
$ npm install gifencoder
Streaming API - Duplex Piping with Writes
You can also stream writes of pixel data (or canvas contexts) to the encoder:
const GIFEncoder = ;const encoder = 854 480;const pngFileStream = ;const fs = ;const stream =;stream;// Alternately, you can wrap the "finish" event in a Promiseawait {stream;stream;};
NB: The chunks that get emitted by your read stream must either by a 1-dimensional bitmap of RGBA
data (either an array or Buffer), or a canvas 2D context
.
Example: Streaming API - Reads
You can also use a streaming API to receive data:
const GIFEncoder = ;const createCanvas = ;const fs = ;const encoder = 320 240;// stream the results as they are available into myanimated.gifencoder;encoderstart;encoder; // 0 for repeat, -1 for no-repeatencoder; // frame delay in msencoder; // image quality. 10 is default.// use node-canvasconst canvas = ;const ctx = canvas;// red rectanglectxfillStyle = '#ff0000';ctx;encoder;// green rectanglectxfillStyle = '#00ff00';ctx;encoder;// blue rectanglectxfillStyle = '#0000ff';ctx;encoder;encoder;
The above code will generate the following animated GIF:
Contributing
gifencoder is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the CONTRIBUTING.md file for more details.
Contributors
gifencoder is only possible due to the excellent work of the following contributors:
Kevin Weiner | kweiner@fmsware.com |
---|---|
Thibault Imbert | http://www.bytearray.org/ |
Eugene Ware | GitHub/eugeneware |
Raine Virta | GitHub/raine |
Paul Ochoa | GitHub/rochoa |
Heikki Pora | GitHub/heikkipora |