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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
const fs = require('fs');
const cp = require('child_process');
const child_process = require("child_process");
const number = require('../../app.json')['signal']['raindrops'];
let bottom = [
"jybgq",
"auvwc",
"mvaws",
"wnujv"
];
let ponies = [...require('../../data/gdapd/members.json').filter(i => {
return fs.existsSync("../../data/metadata/" + i.id + ".json") && !require("../../data/metadata/" + i.id + ".json").species.includes("human");
}), ...require('../../data/ynmuc/members.json').filter(i => {
return fs.existsSync("../../data/metadata/" + i.id + ".json") && !require("../../data/metadata/" + i.id + ".json").species.includes("human");
})];
let columns = Math.ceil(Math.sqrt(ponies.length));
console.log(ponies.length + " ponies, so the image will contain " + columns + "x" + columns + " ponies");
let list = [];
for (let pony of ponies) {
if (list.includes(pony.name) || bottom.includes(pony.id)) continue;
let metadata = require("../../data/metadata/" + pony.id + ".json");
let relations = [...(metadata.marefriends ?? []), ...(metadata.sisters ?? []), ...(metadata.caretakers ?? [])]
list.push(pony.name);
for (let relation of relations) {
let relationPony = ponies.filter(i => i.id === relation.split("/")[1])[0] ?? null;
if (relationPony) {
if (!list.includes(relationPony.name) && !bottom.includes(pony.id)) list.push(relationPony.name);
}
}
}
for (let id of bottom) {
let pony = ponies.filter(i => i.id === id)[0] ?? null;
if (list.includes(pony.name)) continue;
let metadata = require("../../data/metadata/" + pony.id + ".json");
let relations = [...(metadata.marefriends ?? []), ...(metadata.sisters ?? []), ...(metadata.caretakers ?? [])]
list.push(pony.name);
for (let relation of relations) {
let relationPony = ponies.filter(i => i.id === relation.split("/")[1])[0] ?? null;
if (relationPony) {
if (!list.includes(relationPony.name)) list.push(relationPony.name);
}
}
}
let lines = [];
while (list.length > 0) lines.push(list.splice(0, columns));
if (fs.existsSync("./output.png")) fs.unlinkSync("./output.png");
for (let index1 in lines) {
process.stdout.write(index1 + ": ");
index1 = parseInt(index1);
let line = lines[index1];
let toRemove;
for (let index2 in line) {
index2 = parseInt(index2);
let cell = line[index2];
let pony = ponies.filter(i => i.name === cell)[0] ?? null;
process.stdout.write(pony.id);
if (pony) {
if (fs.existsSync("../../../assets/ponies/" + pony.id + ".png")) {
if (!fs.existsSync("./" + index1 + ".png")) {
cp.execFileSync("convert", ["../../../assets/ponies/" + pony.id + ".png", "-filter", "Point", "-resize", "x240", "./" + index1 + ".png"]);
process.stdout.write("...");
toRemove = parseInt(cp.execFileSync("identify", ["-format", "%w", "./" + index1 + ".png"]).toString()) / 2;
process.stdout.write("...");
} else {
let width1 = (index2 + 1) * 240;
let width2 = index2 * 120;
cp.execFileSync("convert", ["../../../assets/ponies/" + pony.id + ".png", "-filter", "Point", "-resize", "x240", "./temp.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["-size", width1 + "x240", "xc:transparent", "canvas.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["canvas.png", "-colorspace", "sRGB", "./temp.png", "-geometry", "+" + width2 + "+0", "-composite", "./temp.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["./" + index1 + ".png", "-background", "none", "-extent", width1 + "x240", "./" + index1 + "-2.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["./" + index1 + "-2.png", "./temp.png", "-background", "none", "-flatten", "-trim", "+repage", "./" + index1 + "-3.png"]);
process.stdout.write(".");
fs.unlinkSync("./" + index1 + "-2.png");
fs.unlinkSync("./" + index1 + ".png");
fs.renameSync("./" + index1 + "-3.png", "./" + index1 + ".png");
process.stdout.write(".");
}
process.stdout.write(", ");
}
}
}
if (!fs.existsSync("./output.png")) {
cp.execFileSync("convert", ["./" + index1 + ".png", "./output.png"]);
process.stdout.write("....");
fs.unlinkSync("./" + index1 + ".png");
process.stdout.write("...");
} else {
let height1 = (index1 + 1) * 480;
let height2 = index1 * 120;
cp.execFileSync("convert", ["./" + index1 + ".png", "-filter", "Point", "-resize", "x240", "./temp.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["-size", (columns * 240) + "x" + height1, "xc:transparent", "canvas.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["canvas.png", "-colorspace", "sRGB", "./temp.png", "-geometry", "+0+" + height2, "-composite", "./temp.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["./output.png", "-background", "none", "-extent", (columns * 240) + "x" + height1, "./output-2.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["./output-2.png", "./temp.png", "-background", "none", "-gravity", "Center", "-flatten", "-trim", "+repage", "./output-3.png"]);
process.stdout.write(".");
fs.unlinkSync("./output-2.png");
fs.unlinkSync("./output.png");
fs.unlinkSync("./temp.png");
fs.unlinkSync("./" + index1 + ".png");
fs.unlinkSync("./canvas.png");
process.stdout.write(".");
fs.renameSync("./output-3.png", "./output.png");
process.stdout.write(".");
}
process.stdout.write("\n");
}
process.stdout.write(".");
let dimensions = cp.execFileSync("identify", ["-format", "%wx%h", "./output.png"]).toString();
process.stdout.write(".");
let highest = Math.max(...dimensions.split("x").map(i => parseInt(i))) + 200;
cp.execFileSync("convert", ["./output.png", "-background", "none", "-gravity", "Center", "-extent", highest + "x" + highest, "./output-2.png"]);
process.stdout.write(".");
cp.execFileSync("magick", ["-size", highest + "x" + highest, "-define", "gradient:direction=North", "gradient:#6acc28-#72ace5", "-colorspace", "sRGB", "gradient.png"]);
process.stdout.write(".");
cp.execFileSync("convert", ["./gradient.png", "./output-2.png", "-colorspace", "sRGB", "-flatten", "./output.png"]);
process.stdout.write(".");
fs.unlinkSync("gradient.png");
fs.unlinkSync("output-2.png");
process.stdout.write(".");
child_process.execFileSync("signal-cli", [ "-a", number, "updateGroup", "--group", "Im1iOlG3TxtiwAad+aVPJ6RsdSN3YCQauz1SmYiMqA8=", "--avatar", __dirname + "/output.png" ]);
process.stdout.write(".");
child_process.execFileSync("signal-cli", [ "-a", number, "sendSyncRequest" ]);
process.stdout.write(".");
console.log("\nComplete!");
|