如何用imagemin压缩图像?

时间:2018-10-08 16:17:05

标签: node.js imagemin

我滥用吗?

let imgBuff = /* my image buffer is here */

console.log("file type", fileType(imgBuff)); // -> debug { ext: 'jpg', mime: 'image/jpeg' }
console.log("before!", imgBuff.toString("ascii").length); // -> before! 28991

imagemin
  .buffer(imgBuff, null, {
    plugins: [imageminJpegtran(), imageminPngquant({ quality: "10", strip: true })]
  })
  .then(files => {
    console.log("after", files.toString("ascii").length); // -> after 28991
  });

我正在尝试其他文件,却再也看不到减小的大小...我缺少什么?

0 个答案:

没有答案