20 lines
556 B
JavaScript
20 lines
556 B
JavaScript
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")
|
|
module.exports = webg |