Standardize public images on WebP and add conversion tooling
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s

This commit is contained in:
Shinuwa 2026-10-23 12:12:02 +02:00
parent 75592d7d7a
commit ca39b76282
883 changed files with 503 additions and 90 deletions

View file

@ -10,6 +10,11 @@ const readJson = async (path) => JSON.parse(await readFile(`website/public/data/
const [aniimos, fr, en] = await Promise.all([readJson("aniimo/aniimos.json"), readJson("aniimo/i18n/fr.json"), readJson("aniimo/i18n/en.json")]);
const data = prepareAniimoData(aniimos, fr, en);
function readWebpCanvasSize(webp) {
assert.equal(webp.toString("ascii", 12, 16), "VP8X");
return [webp.readUIntLE(24, 3) + 1, webp.readUIntLE(27, 3) + 1];
}
test("Aniimo attributes have valid stats and matching totals", () => {
validateAniimoData(aniimos, [fr, en]);
const invalid = structuredClone(aniimos[0]);
@ -24,14 +29,15 @@ test("Aniimo data has valid variants, translations, portraits and icons", async
validateAniimoData(aniimos, [fr, en]);
const game = (await readJson("games.json")).games.find((game) => game.id === "aniimo");
assert.ok(game);
assert.equal(game.images.aniimosCover, "/static/img/aniimo/emberpup__basic_form.png");
assert.equal(game.images.aniimosCover, "/static/img/aniimo/emberpup__basic_form.webp");
const assets = new Set([game.images.cardCover, game.images.heroBg, game.images.aniimosCover, ...data.variants.map((variant) => variant.image)]);
for (const option of Object.values(data.filterOptions).flat()) assets.add(`/static/img/aniimo/${option}.png`);
for (const option of Object.values(data.filterOptions).flat()) assets.add(`/static/img/aniimo/${option}.webp`);
await Promise.all([...assets].map((asset) => access(`website/public${asset}`)));
for (const variant of data.variants) {
const png = await readFile(`website/public${variant.image}`);
assert.equal(png.readUInt32BE(16), 512);
assert.equal(png.readUInt32BE(20), 840);
const webp = await readFile(`website/public${variant.image}`);
assert.equal(webp.toString("ascii", 0, 4), "RIFF");
assert.equal(webp.toString("ascii", 8, 12), "WEBP");
assert.deepEqual(readWebpCanvasSize(webp), [512, 840]);
}
});