-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (38 loc) · 1.18 KB
/
index.js
File metadata and controls
45 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
package: deep-fried-memes
This is a simple example of a deep-fried meme generator.
*/
const imgPath = process.argv[2];
const path = require("path");
const ext = path.extname(imgPath);
const isImage = ext === ".jpg" || ext === ".jpeg" || ext === ".png";
if (!isImage) {
console.log(`skipping ${imgPath}`);
process.exit(0);
}
const Jimp = require("jimp");
const deepFry = (index) => {
Jimp.read(imgPath).then((image) => {
// final path = ./deep-fried-memes/df_${basename}_${index}.${ext}
const finalPath = path.join(
__dirname,
"deep-fried-memes",
`df_${path.basename(imgPath, ext)}_${index}${ext}`
);
image
.color([{ apply: "saturate", params: [100] }])
.contrast(1)
.quality(1)
.posterize(0.5)
.color([{ apply: "hue", params: [Math.floor(Math.random() * 360)] }])
.displace(image, 1 + Math.floor(Math.random() * 15))
.color([{ apply: "saturate", params: [100] }])
// .dither565()
.color([{ apply: "hue", params: [Math.floor(Math.random() * 360)] }])
.write(finalPath);
console.log(`successfullly deep-fried - ${index} - ${imgPath}`);
});
};
for (let i = 1; i <= 1; i++) {
deepFry(i);
}