2019-12-26 17:37:51 +08:00
|
|
|
const convert = require('webp-batch-convert');
|
|
|
|
|
|
|
|
|
|
|
|
let webg = async (dir) => {
|
|
|
|
console.log(dir)
|
|
|
|
const cwebpOpts = {
|
|
|
|
quiet: true, // 不输出详情
|
|
|
|
q: 1// 质量
|
|
|
|
};
|
|
|
|
// 清空输出目录
|
|
|
|
// convert.utils.delDir(__dirname + '/webp');
|
|
|
|
convert.utils.delDir(dir, /\.webp$/);
|
|
|
|
res = convert.cwebp(dir,dir, cwebpOpts);
|
|
|
|
// console.log('total: ', res);
|
|
|
|
convert.utils.delDir(dir, /\.jpg$/);
|
|
|
|
convert.utils.delDir(dir, /\.png$/);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
webg(__dirname + "\\img")
|
2019-12-17 20:55:50 +08:00
|
|
|
module.exports = webg
|