How do I convert a png buffer to a jpg without writing to a file?
问问题
8573 次
1 回答
6
您可以使用https://github.com/aheckmann/gm
var gm = require('gm')
// convert a buffer to a stream
gm(buffer, 'img.png')
.stream('jpg')
.pipe(outputStream);
// convert a buffer to a buffer
gm(buffer, 'img.png')
.toBuffer('PNG',function (err, buffer) {
if (err) return handle(err);
console.log('done!');
})
于 2015-01-16T13:48:40.767 回答