node.js - Image Manipulation in NodeJs using gm -


i have add text on images returned in http response. using gm (graphicmagick) achieve it, getting following error:

events.js:72     throw er; // unhandled 'error' event           ^ error: spawn enoent   @ errnoexception (child_process.js:975:11)   @ process.childprocess._handle.onexit (child_process.js:766:34) 

could pls suggest if there wrong in code:

var http = require('http') gm = require('gm');  http.createserver(function(request, response){     var request_options = {         host: request.headers['host'],         port: 80,         path: request.path,         method: request.method     }      var proxy_request = http.request(request_options, function(proxy_response){         proxy_response.pipe(response);         var data = new buffer(parseint(proxy_response.headers['content-length'],10));         var pos = 0;         proxy_response.on('data', function (chunk) {           chunk.copy(data, pos);           pos += chunk.length;         });          proxy_response.on('end', function () {           gm(data, 'image.jpg')                 .drawtext(10,10,"sample")                 .stream(function streamout (err, stdout, stderr) {                         if (err) return "error";                         stdout.pipe(proxy_response); //pipe response                         stdout.on('error', function(){console.log("error")});                  });         });          proxy_response.on('error', function (err) {                //handle error here         });          response.writehead(proxy_response.statuscode, proxy_response.headers)     })     request.pipe(proxy_request) }).listen(8002) 

thanks in advance.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -