NodeJS图像上传成功,但Resize不能使用GraphicsMagick

我正在尝试调整上传的图片的大小。 我已经testing了差不多的方法,我可以在互联网上find,但没有一个似乎工作。 我能够上传图像到服务器的文件夹,但它仍然保持完整的图像大小。 我错过了什么?

var formidable = require('formidable'), path = require('path'), fs = require('fs'), gm = require('gm'); //handles image upload exports.image = function (req, res) { var form = new formidable.IncomingForm(); form.parse(req, function (err, fields, files) { var file = files.file; var tempPath = file.path; var rename = makeid(); var targetPath = path.resolve('./public/assets/images/upload/'+ file.name ); fs.rename(tempPath, targetPath, function (err) { if (err) { throw err } gm( targetPath).resize(null, 50).on('finish', (function done(file) { console.log('done: ' + file); }).bind(null, file)); return res.json({path: 'assets/images/upload/'+ file.name }) }) }); }; function makeid() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for( var i=0; i < 15; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; }