This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (48 loc) · 1.67 KB
/
index.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { TwitterApi } from "twitter-api-v2";
import jimp from "jimp";
import dotenv from "dotenv";
dotenv.config();
const client = new TwitterApi({
appKey: process.env.appKey,
appSecret: process.env.appSecret,
accessToken: process.env.accessToken,
accessSecret: process.env.accessSecret,
});
let followers_glob = [];
async function saveUserPics() {
const followers = await client.v2.followers("1479752045397790724", {
max_results: 3,
});
followers_glob = followers.data.map((fol) => fol.username);
const user_names = [];
followers.data.forEach(({ username, id }) => user_names.push({id,username}));
const save_pic = async ({id,username}) => {
// Get the user's profile image from the API
const user = await client.v1.user({user_id: id});
const image = await jimp.read(user.profile_image_url_https);
image.write(`${username}.png`);
};
Promise.all(user_names.map(save_pic)).then(image)
}
saveUserPics();
async function image() {
const image = await jimp.read("static/1500x500.png");
let mask = await jimp.read(`${followers_glob[0]}.png`);
const font = await jimp.loadFont("fonts/fnt.fnt");
image.resize(1500, 500);
image.print(font, 100, 110, "Latest followers");
mask.resize(100, 100);
mask.circle();
image.composite(mask, 110, 216);
mask = await jimp.read(`${followers_glob[1]}.png`);
mask.resize(80, 80);
mask.circle();
image.composite(mask, 230, 170);
mask = await jimp.read(`${followers_glob[2]}.png`);
mask.resize(80, 80);
mask.circle();
image.composite(mask, 240, 260);
image.write("static/test.png", async () => {
await client.v1.updateAccountProfileBanner("./static/test.png");
});
}