Skip to content

Instantly share code, notes, and snippets.

View jbouny's full-sized avatar

Jérémy Bouny jbouny

View GitHub Profile
@jbouny
jbouny / nodejs-gif
Created July 3, 2015 15:39
Node.js GIF generation with gifencoder
var GIFEncoder = require('gifencoder');
function createGifEncoder(resolution, response) {
var encoder = new GIFEncoder(resolution.x * 32, resolution.y * 32);
var stream = encoder.createReadStream();
response.type("gif");
stream.pipe(response);
@jbouny
jbouny / nodejs-webm
Last active November 22, 2017 23:04
Node.js WebM generation with whammy and sharp
var Whammy = require('node-whammy'),
sharp = require('sharp');
function canvasToWebp(canvas, callback) {
sharp(canvas.toBuffer()).toFormat(sharp.format.webp).toBuffer(function(e, webpbuffer) {
var webpDataURL = 'data:image/webp;base64,' + webpbuffer.toString('base64');
callback(webpDataURL);
});