如何调整流中图像的大小?使用犀利的图书馆? https://github.com/lovell/sharp
exports.getVehicleImageProfile = function (req, res) {
gfs.findOne({ filename: req.params.filename }, function (err, file) {
if (file) {
const readstream = gfs.createReadStream(file.filename);
readstream.on('data', (chunk) => {
}).pipe(res)
}
});
}
}```
答案 0 :(得分:0)
根据documentation,您可以将流直接传送到 sharp 以调整图像大小:
const s = sharp().resize(200, 200);
readstream.pipe(s).pipe(...);