这段代码用于创建基于高度和宽度参数设置的动态图像..Say localhost:3000/50/50将给出一个图像的宽度50和高度50 ..我我使用的代码是从github获得的。我在我的系统中安装了imageMagick。节点js动态图像 - 错误
var http = require('http');
var url = require('url');
var fs = require('fs');
var gm = require('gm');
var server = http.createServer(function(request, response){
var url_parts = url.parse(request.url).path.substring(1).split("/");
var width = parseInt(url_parts[0]);
var height = parseInt(url_parts[1]);
var max = Math.max(width, height);
if(!isNaN(width) && !isNaN(height))
{
response.writeHead(200, {'content-type': 'image/png'});
gm('nodejs.png').
resize(max, max).
crop(width, height, 0, 0).
stream(function(err, stdout, stderr){
if(err) {
console.log(err)
}
else {
stdout.pipe(response);
}
});
}
else {
response.writeHead(400, {'content-type' : 'text/plain'});
response.end();
}
})
.listen(3000);
这是错误我得到
events.js:72 throw er; // Unhandled 'error' event ^Error: spawn ENOENT at errnoException (child_process.js:980:11) at Process.ChildProcess._handle.onexit (child_process.js:771:34)
文件nodejs.png在同一个目录中存在的该project.What的是,是我做错了吗?
可以请你发布完整的错误信息,并找到代码中的错误行也是如此? – exebook