commit initial

This commit is contained in:
2023-01-30 09:48:23 +01:00
commit 759f1bfb8b
12 changed files with 139 additions and 0 deletions

25
src/index.ts Normal file
View File

@ -0,0 +1,25 @@
import Jimp from 'jimp';
import fs from 'fs';
const invertColors = async (folder: string) => {
try {
const files = fs.readdirSync(folder);
// Filtre cool
const imageFiles = files.filter(file => file.match(/\.(jfif)$/));
for (const file of imageFiles) {
// read image
const image = await Jimp.read(`${folder}/${file}`);
image.invert();
// change name
const newFileName = '.' + file;
// save image with new file name
await image.writeAsync(`${folder}/${newFileName}`);
console.log("Images have been inverted and rename " + '${newFileName}')
}
} catch (error) {
console.error(error);
}
};
invertColors('./images');