Answer the question
In order to leave comments, you need to log in
How to enable Canvas support in NodeJS?
There is a GifShot module in npm (from the guys from Yahoo). A post request arrives at the nodejs server with an array of images in base64 in JSON.
var express = require('express');
var gifshot = require('gifshot');
var app = express();
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded(({ limit: '100mb', extended: true, parameterLimit: 50000 }));
app.post('/gifshot', urlencodedParser, function(req,res){
var imagespost = JSON.parse(req.body.images);
gifshot.createGIF({
images: imagespost,
interval: 0.04,
numFrames: 10,
frameDuration: 1,
gifWidth: 300,
gifHeight: 300,
sampleInterval: 10,
numWorkers: 2
},function(obj) {
if(!obj.error) {
res.send(obj.image);
} else {
res.send(obj.errorMsg);
}
});
});
app.listen(3000);
Answer the question
In order to leave comments, you need to log in
Canvas is a browser API. This is a thing to draw other things in the browser window. Nodejs is not a browser, there is no window and there is no canvas. Don't turn it on at all.
You can, of course, look for emulators for the node or, in extreme cases, raise a virtual browser in the node process. But do you really want this?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question