-2
请先看代码。在这里,我正在拍摄一系列输入,并且照片的名称以数组格式显示。Image Magick模块抛出奇怪的错误(Express js Node js)
for (var i = 0; i < photos.length; i++) {
var x = './images/offers/' + testooo + '/' + photos[i];
var y = './images/offers/' + testooo + '/thumbnails/' + photos[i];
/*
gm(x)
.resizeExact(200, 200)
.write(y, function (err) {
if (!err) console.log('done');
});*/
im.resize({
srcData: fs.readFileSync(x, 'binary'),
width: 200
}, function(err, stdout, stderr) {
if (err) {
console.log(err);
console.log('error part');
}
fs.writeFileSync(y, stdout, 'binary');
console.log('Resized Photos');
});
}
你可以看到,难懂的部分是有它抛出这个错误。
events.js:85
throw er; // Unhandled 'error' event
^
Error: write EOF
at exports._errnoException (util.js:746:11)
at WriteWrap.afterWrite (net.js:775:14)
现在一两件事我想加你可以看到,在评论部分有一些东西开始通用文字。我也尝试使用图形magick模块。代码运行时没有任何错误,但没有创建拇指指甲。图形Magick模块使用图像magick模块工作。
请让我知道我做错了什么。
在你调用'im.resize()'之前,你可以像[图](http://stackoverflow.com/a/17699926/690573)一样调用'fs.stat()',并显示输出?这将帮助我们排除故障。 –
@NathanJones谢谢你的时间。我刚刚做到了,File Exists打印在我的控制台上。 –
如果你打开一个命令行shell,你可以运行'convert -version'吗?根据[this](http://stackoverflow.com/a/21871588/690573),你可能实际上没有安装imagemagick。 –