summaryrefslogtreecommitdiff
path: root/includes/external
diff options
context:
space:
mode:
Diffstat (limited to 'includes/external')
-rw-r--r--includes/external/photo/5-2.pngbin0 -> 6935 bytes
-rw-r--r--includes/external/photo/5.pngbin0 -> 6000 bytes
-rw-r--r--includes/external/photo/canvas.pngbin0 -> 363 bytes
-rw-r--r--includes/external/photo/index.js162
-rw-r--r--includes/external/photo/output.pngbin0 -> 64235 bytes
-rw-r--r--includes/external/photo/run.sh3
-rw-r--r--includes/external/photo/temp.pngbin0 -> 2079 bytes
7 files changed, 165 insertions, 0 deletions
diff --git a/includes/external/photo/5-2.png b/includes/external/photo/5-2.png
new file mode 100644
index 0000000..5319d67
--- /dev/null
+++ b/includes/external/photo/5-2.png
Binary files differ
diff --git a/includes/external/photo/5.png b/includes/external/photo/5.png
new file mode 100644
index 0000000..bc6d8d8
--- /dev/null
+++ b/includes/external/photo/5.png
Binary files differ
diff --git a/includes/external/photo/canvas.png b/includes/external/photo/canvas.png
new file mode 100644
index 0000000..a6e5e8f
--- /dev/null
+++ b/includes/external/photo/canvas.png
Binary files differ
diff --git a/includes/external/photo/index.js b/includes/external/photo/index.js
new file mode 100644
index 0000000..fda0163
--- /dev/null
+++ b/includes/external/photo/index.js
@@ -0,0 +1,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!"); \ No newline at end of file
diff --git a/includes/external/photo/output.png b/includes/external/photo/output.png
new file mode 100644
index 0000000..81e14c9
--- /dev/null
+++ b/includes/external/photo/output.png
Binary files differ
diff --git a/includes/external/photo/run.sh b/includes/external/photo/run.sh
new file mode 100644
index 0000000..19c9c11
--- /dev/null
+++ b/includes/external/photo/run.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+rm *.png
+nice -n 19 node index.js \ No newline at end of file
diff --git a/includes/external/photo/temp.png b/includes/external/photo/temp.png
new file mode 100644
index 0000000..ece0ab8
--- /dev/null
+++ b/includes/external/photo/temp.png
Binary files differ