Beispiel #1
0
function getGif(width, height) {
  var hwm = 128 * 100 * 1024 // brycebaril told me to
  var gif = new GifEncoder(width, height, {
    'highWaterMark': hwm
  })

  gif.setDelay(100)
  gif.setRepeat(0)

  gif.writeHeader()

  return gif
}
Beispiel #2
0
http.createServer(function (req, res) {
  
  var hash = url.parse(req.url, true);
  if (hash.pathname === '/pixel') {
    var color = hash.query['color'];

    res.writeHead(200, {'Content-Type': 'image/gif'});

    var gif = new GifEncoder(1, 1);
    gif.pipe(res);
    gif.writeHeader();
    gif.addFrame([hexToR(color), hexToG(color), hexToB(color), 1]);
    gif.finish();
  }
  else {
    res.writeHead(404);
    res.end("Not Found");
  }

}).listen(process.env.PORT || 3000, '127.0.0.1');