【发布时间】:2014-07-26 23:29:03
【问题描述】:
我正在使用 SailsJS(测试版)。我正在尝试找到一种方法来使用 graphicsmagick 在调用 Skipper 函数req.file('inputName').upload() 之前使用 SailsJS-beta 中的 Skipper 解析的流来调整图像大小。
我的目标是在上传之前拍摄我的大型原始图片并调整其大小。 Sails beta 引入了文档不足的 Skipper-file-parser(至少我不明白)。请帮助我了解如何在上传前调整图像大小。
这有效(我的控制器操作中的代码):
req.file('fileName').upload('storedImage.png', function(err, files){
// File is now uploaded to storedImage.png
});
我想要的是这样的:
// Read the file stream into a file upload
var stream = req.file('fileName');
gm(stream).resize(200, 200).write('storedImage.png', function(err){
// File is now resized to 200x200 px and uploaded to storedImage.png
});
我的问题是:如何正确地从 req.file('fileName') 获取流以将其发送给 gm?
【问题讨论】:
标签: image sails.js graphicsmagick skipper