Skip to content

Instantly share code, notes, and snippets.

@ShinChven
Created September 25, 2020 17:26
Show Gist options
  • Save ShinChven/12f4ccbd10a9d8c813c669a835faa93d to your computer and use it in GitHub Desktop.
Save ShinChven/12f4ccbd10a9d8c813c669a835faa93d to your computer and use it in GitHub Desktop.
sharp-bulk
const path = require('path');
const fs = require('fs-extra');
const sharp = require('sharp');
const dir = '';
const convert = async () => {
const files = await fs.readdir(dir);
for (let i =0 ; i<files.length;i++){
const image = path.join(dir,files[i]);
await sharp(image).png().toFile(`${image}.png`);
}
return Promise.resolve(files);
};
convert().then(res => {
console.log('done', res);
}).catch(err => console.error(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment