压缩下载完成
This commit is contained in:
18
bin/webg.js
Normal file
18
bin/webg.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const convert = require('webp-batch-convert');
|
||||
|
||||
|
||||
let webg = async (dir) => {
|
||||
const cwebpOpts = {
|
||||
quiet: true, // 不输出详情
|
||||
q: 5 // 质量
|
||||
};
|
||||
// 清空输出目录
|
||||
// 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;
|
||||
}
|
||||
module.exports = webg
|
||||
Reference in New Issue
Block a user