Streaming server-side animated (and non-animated) gif generation for node.js
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:
var GIFEncoder = ;var encoder = 854 480;var pngFileStream = ;var fs = ;;
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
Example: Streaming API - Reads
You can also use a streaming API to receive data:
var GIFEncoder = ;var Canvas = ;var fs = ;var 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-canvasvar canvas = 320 240;var 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:
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.
gifencoder is only possible due to the excellent work of the following contributors: