Initial commit: Luminary photo catalog and RAW editor

Browser-based photo catalog with an optional team server (SQLite + LibRaw).
Local database, uploaded photos, build output and dependencies are gitignored.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-23 15:19:25 +00:00
commit cd52a2f82f
121 changed files with 101872 additions and 0 deletions
+152
View File
@@ -0,0 +1,152 @@
/**
* A small, self-contained ICC v2 sRGB display profile.
*
* It is generated rather than shipped as a binary so the export pipeline can
* tag sRGB files without adding a third-party profile asset. The matrix and
* gamma describe the standard sRGB primaries; the browser already converted
* the working pixels into sRGB when it decoded the source image.
*/
let cached: Uint8Array | null = null;
function be32(out: DataView, offset: number, value: number) {
out.setUint32(offset, value >>> 0, false);
}
function be16(out: DataView, offset: number, value: number) {
out.setUint16(offset, value & 0xffff, false);
}
function s15(value: number) {
return Math.round(value * 65536) >>> 0;
}
function ascii(text: string) {
return new TextEncoder().encode(text);
}
function pad4(value: number) {
return (value + 3) & ~3;
}
function xyzTag(x: number, y: number, z: number) {
const data = new Uint8Array(20);
const view = new DataView(data.buffer);
data.set(ascii('XYZ '), 0);
be32(view, 8, s15(x));
be32(view, 12, s15(y));
be32(view, 16, s15(z));
return data;
}
function curveTag() {
// ICC v2 curveType with the piecewise sRGB transfer function sampled at
// 1024 points. A gamma-2.2 shortcut is close, but this is exact to the
// standard (within 16-bit quantisation) and still readable by old CMMs.
const samples = 1024;
const data = new Uint8Array(12 + samples * 2);
const view = new DataView(data.buffer);
data.set(ascii('curv'), 0);
be32(view, 8, samples);
for (let index = 0; index < samples; index++) {
const linear = index / (samples - 1);
const encoded =
linear <= 0.04045
? linear / 12.92
: ((linear + 0.055) / 1.055) ** 2.4;
be16(view, 12 + index * 2, Math.round(encoded * 65535));
}
return data;
}
function descTag(text: string) {
const value = new TextEncoder().encode(text);
const size = pad4(12 + value.length + 1 + 4 + 4);
const data = new Uint8Array(size);
const view = new DataView(data.buffer);
data.set(ascii('desc'), 0);
be32(view, 8, value.length + 1);
data.set(value, 12);
data[12 + value.length] = 0;
// Unicode language code and count are both zero.
return data;
}
function textTag(text: string) {
const value = new TextEncoder().encode(text);
const size = pad4(8 + value.length + 1);
const data = new Uint8Array(size);
const view = new DataView(data.buffer);
data.set(ascii('text'), 0);
data.set(value, 8);
data[8 + value.length] = 0;
return data;
}
export function srgbProfile(): Uint8Array {
if (cached) return cached;
// sRGB primaries adapted to the D50 profile connection space.
const tags: { sig: string; data: Uint8Array }[] = [
{ sig: 'desc', data: descTag('sRGB IEC61966-2.1 (Luminary)') },
{ sig: 'cprt', data: textTag('No copyright, use freely') },
{ sig: 'wtpt', data: xyzTag(0.9642, 1.0, 0.8249) },
{ sig: 'rXYZ', data: xyzTag(0.4360747, 0.2225045, 0.0139322) },
{ sig: 'gXYZ', data: xyzTag(0.3850649, 0.7168786, 0.0971045) },
{ sig: 'bXYZ', data: xyzTag(0.1430804, 0.0606169, 0.7141733) },
{ sig: 'rTRC', data: curveTag() },
{ sig: 'gTRC', data: curveTag() },
{ sig: 'bTRC', data: curveTag() },
];
const tableSize = 4 + tags.length * 12;
let offset = 128 + tableSize;
const placed = tags.map((tag) => {
offset = pad4(offset);
const at = offset;
offset += tag.data.length;
return { ...tag, at };
});
const total = pad4(offset);
const data = new Uint8Array(total);
const view = new DataView(data.buffer);
// Header. Date is fixed so identical exports have identical profile bytes.
be32(view, 0, total);
data.set(ascii('LNRM'), 4);
be32(view, 8, 0x02100000);
data.set(ascii('mntr'), 12);
data.set(ascii('RGB '), 16);
data.set(ascii('XYZ '), 20);
be16(view, 24, 2026);
be16(view, 26, 1);
be16(view, 28, 1);
be16(view, 30, 0);
be16(view, 32, 0);
be16(view, 34, 0);
data.set(ascii('acsp'), 36);
be32(view, 40, 0);
be32(view, 44, 0);
be32(view, 48, 0);
be32(view, 52, 0);
be32(view, 56, 0);
be32(view, 60, 0);
be32(view, 64, 0); // perceptual rendering intent
be32(view, 68, 0x0000f6d6); // D50 X 0.9642
be32(view, 72, 0x00010000); // D50 Y 1.0
be32(view, 76, 0x0000d32d); // D50 Z 0.8249
data.set(ascii('LNRM'), 80);
// bytes 84-127 (profile ID and reserved) remain zero.
be32(view, 128, placed.length);
placed.forEach((tag, index) => {
const at = 132 + index * 12;
data.set(ascii(tag.sig), at);
be32(view, at + 4, tag.at);
be32(view, at + 8, tag.data.length);
data.set(tag.data, tag.at);
});
cached = data;
return data;
}