Match EXIF lens names by brand and share team calibrations

EXIF folds the brand into the focal range ("EF75-300mm"), so split letters
from digits before scoring, keep the score a pure name score that a caller can
trust, and rank a same-mount-family lens higher without filtering. Auto-match
now declines below 0.75 rather than applying the best of a bad list.

Lenses the bundled database lacks can be measured in-house: /api/lens-profiles
stores calibrations in SQLite, the Optics panel edits them and marks them
"Team", and search treats them as ordinary entries.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 05:49:47 +00:00
parent 16456c3c69
commit 749047ae9e
13 changed files with 1363 additions and 15 deletions
+90
View File
@@ -204,6 +204,25 @@ db.exec(`
prune_notified_at INTEGER,
last_quota_email_at INTEGER
);
/* Lens calibrations measured by the team, alongside the bundled database. */
CREATE TABLE IF NOT EXISTS lens_profiles (
id TEXT PRIMARY KEY,
maker TEXT NOT NULL,
model TEXT NOT NULL,
mount TEXT NOT NULL DEFAULT '',
crop REAL NOT NULL DEFAULT 1,
aspect REAL NOT NULL DEFAULT 0,
center_x REAL NOT NULL DEFAULT 0,
center_y REAL NOT NULL DEFAULT 0,
notes TEXT NOT NULL DEFAULT '',
data TEXT NOT NULL,
created_by TEXT NOT NULL DEFAULT '',
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS lens_profiles_updated ON lens_profiles(updated_at);
`);
/* Databases created before account disabling existed get the column in place. */
@@ -544,6 +563,28 @@ const q = {
kvSet: db.prepare(
'INSERT INTO kv (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value',
),
allLensProfiles: db.prepare(
'SELECT * FROM lens_profiles ORDER BY maker COLLATE NOCASE ASC, model COLLATE NOCASE ASC',
),
lensProfile: db.prepare('SELECT * FROM lens_profiles WHERE id = ?'),
upsertLensProfile: db.prepare(`
INSERT INTO lens_profiles
(id, maker, model, mount, crop, aspect, center_x, center_y, notes, data, created_by, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(id) DO UPDATE SET
maker = excluded.maker,
model = excluded.model,
mount = excluded.mount,
crop = excluded.crop,
aspect = excluded.aspect,
center_x = excluded.center_x,
center_y = excluded.center_y,
notes = excluded.notes,
data = excluded.data,
updated_at = excluded.updated_at
`),
deleteLensProfile: db.prepare('DELETE FROM lens_profiles WHERE id = ?'),
};
function parse(json) {
@@ -1113,3 +1154,52 @@ export const kv = {
},
set: (key, value) => q.kvSet.run(key, JSON.stringify(value)),
};
function lensProfileFromRow(row) {
const data = parse(row.data) ?? {};
return {
id: row.id,
maker: row.maker,
model: row.model,
mount: row.mount,
crop: Number(row.crop),
aspect: Number(row.aspect),
centerX: Number(row.center_x),
centerY: Number(row.center_y),
notes: row.notes,
d: Array.isArray(data.d) ? data.d : [],
t: Array.isArray(data.t) ? data.t : [],
v: Array.isArray(data.v) ? data.v : [],
createdBy: row.created_by,
createdAt: row.created_at,
updatedAt: row.updated_at,
};
}
/** Team-measured calibrations, shared by every signed-in member. */
export const lensProfiles = {
list: () => q.allLensProfiles.all().map(lensProfileFromRow),
get: (id) => {
const row = q.lensProfile.get(String(id));
return row ? lensProfileFromRow(row) : null;
},
save: (record) => {
q.upsertLensProfile.run(
record.id,
record.maker,
record.model,
record.mount ?? '',
Number(record.crop ?? 1),
Number(record.aspect ?? 0),
Number(record.centerX ?? 0),
Number(record.centerY ?? 0),
record.notes ?? '',
JSON.stringify({ d: record.d ?? [], t: record.t ?? [], v: record.v ?? [] }),
record.createdBy ?? '',
record.createdAt ?? Date.now(),
record.updatedAt ?? Date.now(),
);
return lensProfiles.get(record.id);
},
remove: (id) => q.deleteLensProfile.run(String(id)).changes > 0,
};