2024-03-16 19:40:59 +01:00
|
|
|
import { run } from "https://deno.land/x/run_simple/mod.ts";
|
2024-09-09 00:30:56 +02:00
|
|
|
import { join } from "jsr:@std/path@0.224.0";
|
2024-03-16 19:40:59 +01:00
|
|
|
|
|
|
|
const IMG_DIR = "./public/gen-img/events";
|
|
|
|
|
|
|
|
const data = {};
|
|
|
|
for await (const f of Deno.readDir(IMG_DIR)) {
|
|
|
|
const [name, ext] = f.name.split(".");
|
|
|
|
if (ext !== "png") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const explain = await run(`identify ${join(IMG_DIR, f.name)}`);
|
|
|
|
const [_, format, resolution] = explain.split(" ");
|
|
|
|
const [width, height] = resolution.split("x").map((c) => Number(c));
|
|
|
|
|
|
|
|
data[name] = { format, width, height, ratio: width / height };
|
|
|
|
}
|
|
|
|
|
|
|
|
await Deno.writeTextFile(
|
|
|
|
"./src/gen-images.json",
|
|
|
|
JSON.stringify(data, null, 2),
|
|
|
|
);
|
|
|
|
console.log(`File ./src/gen-images.json saved`);
|