I'm trying to use the imagemin buffer function: https://github.com/imagemin/imagemin
file.on('data', function (d) {
fileBuffer = Buffer.concat([fileBuffer, d]);
}).on('end', function () {
imagemin.buffer(fileBuffer, {
plugins: [
imageminMozjpeg(),
imageminPngquant({quality: '80'})
]
}).then(function (file) {
console.log(file);
}, function (err) {
console.dir(err);
});
for some reason its not working. does anyone know why?
imagemin.buffer function works right, but you can have problem with end event. I believe your function has never been called.
Below you can see example with bluebird modification.