我不知道这个错误来自哪里,我希望你能帮助我。我是节点新手,正在尝试使用 imagemagick 调整图像大小:
var express = require('express'),
fs = require('fs'),
gm = require('gm'),
imagemagick = require('imagemagick'),
var gm = require('gm').subClass({ imageMagick: true });
var app = express();
app.get('/', function (req, res) {
console.log(__dirname + "/public/photos/4af1e720-a662-11e3-952c-61812ab60f67.jpg");
imagemagick.resize({
srcData: fs.readFileSync(__dirname + "/public/photos/4af1e720-a662-11e3-952c-61812ab60f67.jpg", 'binary'),
width: "400"
}, function(err,stdout,stderr){
if (err) console.log(err);
fs.writeFile(__dirname + "/public/photos/thumbnail/4af1e720-a662-11e3-952c-61812ab60f67.jpg", stdout, 'binary');
});
});
我得到以下信息:
我已经检查了文件夹 thumbnail/ 存在,并且图像存在。你知道还会发生什么吗?
/Users/ik/Dropbox/snapgram/public/photos/4af1e720-a662-11e3-952c-61812ab60f67.jpg
events.js:72
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at errnoException (net.js:904:11)
at Object.afterWrite (net.js:720:19)
computername:snapgram ik$