Merge pull request #42 from poli0981/feat/gallery-real-photos

feat(gallery): replace the demo album with 34 real photos in 5 albums
This commit is contained in:
poli0981 authored and GitHub committed 2026-08-10 01:18:27 +07:00
commit 4395717d22
60 files changed
+278 -98

No files matched your search

-1
View File
@@ -26,7 +26,6 @@
"format:check": "prettier --check .",
"knip": "knip",
"deploy": "wrangler deploy --config ./dist/server/wrangler.json",
"gen-demo-gallery": "node scripts/gen-demo-gallery.mjs",
"strip-exif": "node scripts/strip-exif.mjs",
"check-exif": "node scripts/check-exif.mjs"
},
-51
View File
@@ -1,51 +0,0 @@
// Generate EXIF-clean placeholder images for the demo gallery album.
// One-off helper: run `npm run gen-demo-gallery`, commit the output JPGs.
// Replace src/assets/gallery/demo/ with real photos later (run strip-exif on them).
import { mkdir } from "node:fs/promises";
import { join } from "node:path";
import sharp from "sharp";
const OUT = "src/assets/gallery/demo";
await mkdir(OUT, { recursive: true });
const W = 1600;
const H = 1067; // 3:2
// Base colours (ink-night → accent hues), matching the site palette mood.
const HUES = [
[31, 111, 235],
[46, 160, 67],
[219, 109, 40],
[139, 92, 246],
[217, 70, 90],
];
for (let i = 0; i < HUES.length; i++) {
const [r, g, b] = HUES[i];
const buf = Buffer.alloc(W * H * 3);
for (let y = 0; y < H; y++) {
const t = y / H; // vertical fade toward near-black
const rr = Math.round(r * (1 - t * 0.78) + 13 * t);
const gg = Math.round(g * (1 - t * 0.78) + 17 * t);
const bb = Math.round(b * (1 - t * 0.78) + 23 * t);
for (let x = 0; x < W; x++) {
const o = (y * W + x) * 3;
buf[o] = rr;
buf[o + 1] = gg;
buf[o + 2] = bb;
}
}
const label = String(i + 1).padStart(2, "0");
const svg = Buffer.from(
`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}">` +
`<text x="50%" y="53%" font-family="sans-serif" font-size="240" font-weight="700" ` +
`fill="#ffffff" fill-opacity="0.88" text-anchor="middle">${label}</text></svg>`,
);
const file = join(OUT, `demo-${label}.jpg`);
// sharp writes no metadata unless asked → EXIF-clean by construction.
await sharp(buf, { raw: { width: W, height: H, channels: 3 } })
.composite([{ input: svg }])
.jpeg({ quality: 82 })
.toFile(file);
console.log(`wrote ${file}`);
}
console.log(`done: ${HUES.length} placeholder image(s)`);
+42 -6
View File
@@ -1,7 +1,15 @@
// Strip ALL metadata (EXIF/GPS/serial/XMP) from images by re-encoding with sharp.
// Prepare photos for committing: strip ALL metadata AND enforce the size budget.
// Run manually BEFORE committing any photo: `npm run strip-exif src/assets/gallery/<album>`
// sharp writes no metadata unless asked; `.rotate()` bakes EXIF orientation into pixels first.
import { readdir, readFile, writeFile } from "node:fs/promises";
//
// Two jobs, because docs 04 §5 states two rules for a committed photo and having them in
// separate tools meant the second one was never actually applied:
// 1. No metadata. sharp writes none unless asked; `.rotate()` bakes EXIF orientation
// into the pixels first so the image still looks right after the metadata is gone.
// (`scripts/check-exif.mjs` is the CI gate that fails if this was skipped.)
// 2. Max 2560px on the long edge, max ~1.5MB. Phone photos arrive at 6048x8064 / 2.5MB,
// which is a pointless amount of bytes for a 400-800px gallery thumbnail and blows
// out both the repo and the Astro build.
import { readdir, readFile, writeFile, stat } from "node:fs/promises";
import { join, extname } from "node:path";
import sharp from "sharp";
@@ -12,13 +20,41 @@ if (!dir) {
}
const EXT = new Set([".jpg", ".jpeg", ".png", ".webp", ".avif"]);
const MAX_EDGE = 2560;
// mozjpeg at 85 rather than plain 82: stripping metadata always costs one re-encode
// generation, and mozjpeg buys back enough bytes that already-compressed phone photos
// don't come out *larger* than they went in.
const QUALITY = 85;
const files = (await readdir(dir)).filter((f) => EXT.has(extname(f).toLowerCase()));
let saved = 0;
for (const f of files) {
const p = join(dir, f);
const before = (await stat(p)).size;
const input = await readFile(p); // read fully first, then overwrite the same path
const out = await sharp(input).rotate().toBuffer();
let pipeline = sharp(input).rotate();
const { width, height } = await sharp(input).metadata();
const resized = Math.max(width ?? 0, height ?? 0) > MAX_EDGE;
if (resized) {
// `withoutEnlargement` is belt-and-braces; the guard above already covers it.
pipeline = pipeline.resize({ width: MAX_EDGE, height: MAX_EDGE, fit: "inside" });
}
const ext = extname(f).toLowerCase();
if (ext === ".jpg" || ext === ".jpeg") {
pipeline = pipeline.jpeg({ quality: QUALITY, mozjpeg: true });
}
const out = await pipeline.toBuffer();
await writeFile(p, out);
console.log(`stripped ${p}`);
saved += before - out.length;
const note = resized ? `${width}x${height} -> max ${MAX_EDGE}px` : "metadata only";
console.log(
` ${f.padEnd(20)} ${(before / 1024).toFixed(0)}KB -> ${(out.length / 1024).toFixed(0)}KB (${note})`,
);
}
console.log(`done: ${files.length} image(s)`);
console.log(`done: ${files.length} image(s), ${(saved / 1024 / 1024).toFixed(2)}MB saved`);
-22
View File
@@ -1,22 +0,0 @@
{
"demo-01.jpg": {
"vi": "Ảnh mẫu 01 — gradient xanh dương sang mực đêm",
"en": "Demo image 01 — blue to ink-night gradient"
},
"demo-02.jpg": {
"vi": "Ảnh mẫu 02 — gradient xanh lá sang mực đêm",
"en": "Demo image 02 — green to ink-night gradient"
},
"demo-03.jpg": {
"vi": "Ảnh mẫu 03 — gradient cam sang mực đêm",
"en": "Demo image 03 — orange to ink-night gradient"
},
"demo-04.jpg": {
"vi": "Ảnh mẫu 04 — gradient tím sang mực đêm",
"en": "Demo image 04 — purple to ink-night gradient"
},
"demo-05.jpg": {
"vi": "Ảnh mẫu 05 — gradient đỏ sang mực đêm",
"en": "Demo image 05 — red to ink-night gradient"
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

+10
View File
@@ -0,0 +1,10 @@
{
"dev-01.jpg": {
"vi": "Màn hình làm việc ngẫu nhiên — IDE trong hình là RustRover",
"en": "A random working screen — the IDE here is RustRover"
},
"dev-02.jpg": {
"vi": "Màn hình làm việc với Claude",
"en": "A working screen with Claude"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

+82
View File
@@ -0,0 +1,82 @@
{
"game-01.jpg": {
"vi": "Kugayama Shiori's Death Diary — một trong các ending",
"en": "Kugayama Shiori's Death Diary — one of the endings"
},
"game-02.jpg": {
"vi": "AI Limit — đang đánh boss",
"en": "AI Limit — mid boss fight"
},
"game-03.jpg": {
"vi": "Ảnh chụp màn hình từ một game khác",
"en": "A screenshot from another game"
},
"game-04.jpg": {
"vi": "Ảnh chụp màn hình từ một game khác",
"en": "A screenshot from another game"
},
"game-05.jpg": {
"vi": "Ảnh chụp màn hình từ một game khác",
"en": "A screenshot from another game"
},
"game-06.jpg": {
"vi": "Kugayama Shiori's Death Diary — một ảnh chụp ngẫu nhiên",
"en": "Kugayama Shiori's Death Diary — a random capture"
},
"game-07.jpg": {
"vi": "AI Limit — cutscene của boss",
"en": "AI Limit — a boss cutscene"
},
"game-08.jpg": {
"vi": "AI Limit — cutscene của boss",
"en": "AI Limit — a boss cutscene"
},
"game-09.jpg": {
"vi": "Ảnh chụp màn hình từ một game khác",
"en": "A screenshot from another game"
},
"game-10.jpg": {
"vi": "Ninja Gaiden 4 — nhân vật đang điều khiển",
"en": "Ninja Gaiden 4 — the player character"
},
"game-11.jpg": {
"vi": "Ninja Gaiden 4 — cutscene của boss",
"en": "Ninja Gaiden 4 — a boss cutscene"
},
"game-12.jpg": {
"vi": "Ninja Gaiden 4 — một NPC nữ",
"en": "Ninja Gaiden 4 — a female NPC"
},
"game-13.jpg": {
"vi": "AI Limit — cutscene của boss",
"en": "AI Limit — a boss cutscene"
},
"game-14.jpg": {
"vi": "AI Limit — nhân vật đang điều khiển",
"en": "AI Limit — the player character"
},
"game-15.jpg": {
"vi": "AI Limit — nhân vật đang điều khiển",
"en": "AI Limit — the player character"
},
"game-16.jpg": {
"vi": "AI Limit — cutscene của boss",
"en": "AI Limit — a boss cutscene"
},
"game-17.jpg": {
"vi": "Type-NOISE: Shonen Shojo — cutscene chụp ngẫu nhiên",
"en": "Type-NOISE: Shonen Shojo — a cutscene, captured at random"
},
"game-18.jpg": {
"vi": "Type-NOISE: Shonen Shojo — cutscene chụp ngẫu nhiên",
"en": "Type-NOISE: Shonen Shojo — a cutscene, captured at random"
},
"game-19.jpg": {
"vi": "Type-NOISE: Shonen Shojo — cutscene chụp ngẫu nhiên",
"en": "Type-NOISE: Shonen Shojo — a cutscene, captured at random"
},
"game-20.jpg": {
"vi": "Ảnh chụp màn hình từ một game khác",
"en": "A screenshot from another game"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

+30
View File
@@ -0,0 +1,30 @@
{
"home-01.jpg": {
"vi": "Sân vườn trước nhà",
"en": "The garden in front of the house"
},
"home-02.jpg": {
"vi": "Chậu hoa ngoài sân (1)",
"en": "A potted plant in the yard (1)"
},
"home-03.jpg": {
"vi": "Chậu hoa ngoài sân (2)",
"en": "A potted plant in the yard (2)"
},
"home-04.jpg": {
"vi": "Khu vực sân sau, sáng sớm",
"en": "The back yard, early morning"
},
"home-05.jpg": {
"vi": "Khu vực sân trước lúc trời tối",
"en": "The front yard after dark"
},
"home-06.jpg": {
"vi": "Sân sau chiều muộn, dưới ánh hoàng hôn",
"en": "The back yard in late afternoon, in sunset light"
},
"home-07.jpg": {
"vi": "Sân trước vào một buổi sáng bình thường",
"en": "The front yard on an ordinary morning"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

+10
View File
@@ -0,0 +1,10 @@
{
"meal-01.jpg": {
"vi": "Một bữa tự nấu trong ngày",
"en": "An everyday meal, cooked at home"
},
"meal-02.jpg": {
"vi": "Một bữa tự nấu khác",
"en": "Another home-cooked meal"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

+14
View File
@@ -0,0 +1,14 @@
{
"portrait-01.jpg": {
"vi": "Ảnh selfie ngẫu nhiên (1)",
"en": "A casual selfie (1)"
},
"portrait-02.jpg": {
"vi": "Ảnh selfie ngẫu nhiên (2)",
"en": "A casual selfie (2)"
},
"portrait-03.jpg": {
"vi": "Ảnh selfie ngẫu nhiên (3)",
"en": "A casual selfie (3)"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

-9
View File
@@ -1,9 +0,0 @@
---
title: "Demo album"
lang: en
translationKey: demo
date: 2026-07-19
description: "Demo album with gradient placeholder images — swap for real photos later (run strip-exif)."
album: demo
coverIndex: 0
---
-9
View File
@@ -1,9 +0,0 @@
---
title: "Album mẫu"
lang: vi
translationKey: demo
date: 2026-07-19
description: "Album demo với ảnh nền gradient — thay bằng ảnh thật sau (nhớ chạy strip-exif)."
album: demo
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Desk"
lang: en
translationKey: dev
date: 2026-08-10
description: "Screens mid-work — an IDE, a terminal, and sometimes an AI."
album: dev
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Góc làm việc"
lang: vi
translationKey: dev
date: 2026-08-10
description: "Màn hình lúc đang code — IDE, terminal, và đôi khi là một con AI."
album: dev
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "In-game captures"
lang: en
translationKey: game
date: 2026-08-10
description: "Screenshots from a few games I have played. Characters, settings and all in-game imagery belong to their respective developers and publishers."
album: game
coverIndex: 1
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Ảnh trong game"
lang: vi
translationKey: game
date: 2026-08-10
description: "Ảnh chụp màn hình từ vài tựa game đã chơi. Nhân vật, bối cảnh và mọi hình ảnh trong game thuộc về nhà phát triển và nhà phát hành tương ứng."
album: game
coverIndex: 1
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Around the house"
lang: en
translationKey: home
date: 2026-08-10
description: "Front yard, back yard, and a few potted plants — home at different hours of the day."
album: home
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Quanh nhà"
lang: vi
translationKey: home
date: 2026-08-10
description: "Sân trước, sân sau, và mấy chậu cây — nhà nhìn từ những giờ khác nhau trong ngày."
album: home
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Meals"
lang: en
translationKey: meal
date: 2026-08-10
description: "Home cooking — no recipes, nothing staged."
album: meal
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Bữa ăn"
lang: vi
translationKey: meal
date: 2026-08-10
description: "Những bữa tự nấu — không công thức, không dàn dựng."
album: meal
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Portraits"
lang: en
translationKey: portrait
date: 2026-08-10
description: "A few selfies, taken at random."
album: portrait
coverIndex: 0
---
+9
View File
@@ -0,0 +1,9 @@
---
title: "Chân dung"
lang: vi
translationKey: portrait
date: 2026-08-10
description: "Vài tấm selfie chụp ngẫu nhiên."
album: portrait
coverIndex: 0
---