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
+64
View File
@@ -34,6 +34,7 @@ import {
getPhoto,
invites,
kv,
lensProfiles,
listEvents,
listPhotos,
livePhotoBytes,
@@ -89,6 +90,7 @@ import {
} from './bridge.mjs';
import { cameraThumb16, jpegInfo, makeThumb, toJpegProxy } from './imaging.mjs';
import { createZip } from './zip.mjs';
import { parseCalibration } from './lensCalibration.mjs';
import {
cancelPrune,
quotaState,
@@ -1858,6 +1860,68 @@ route('PUT', '/api/presets', async ({ req, res }) => {
json(res, 200, { ok: true });
});
/* ---------------------------------------------------- team lens calibrations */
route('GET', '/api/lens-profiles', async ({ req, res }) => {
const user = currentUser(req);
if (!user) return error(res, 401, 'Not signed in');
json(res, 200, { profiles: lensProfiles.list() });
});
route('POST', '/api/lens-profiles', async ({ req, res }) => {
const user = currentUser(req);
if (!user) return error(res, 401, 'Not signed in');
const body = await readJson(req, 256 * 1024);
const parsed = parseCalibration(body);
if (parsed.error) return error(res, 400, parsed.error);
const now = Date.now();
const profile = lensProfiles.save({
...parsed.value,
id: crypto.randomUUID(),
createdBy: user.id,
createdAt: now,
updatedAt: now,
});
json(res, 201, { profile });
});
/** Any member can read the team's calibrations; the author or an admin edits them. */
function editableProfile(id, user) {
const profile = lensProfiles.get(id);
if (!profile) return { status: 404, message: 'No such lens profile' };
if (profile.createdBy !== user.id && user.role !== 'admin') {
return { status: 403, message: 'Only the member who added this profile or an admin can change it' };
}
return { profile };
}
route('PUT', '/api/lens-profiles/:id', async ({ req, res, params }) => {
const user = currentUser(req);
if (!user) return error(res, 401, 'Not signed in');
const found = editableProfile(params.id, user);
if (found.status) return error(res, found.status, found.message);
const body = await readJson(req, 256 * 1024);
const parsed = parseCalibration(body);
if (parsed.error) return error(res, 400, parsed.error);
const profile = lensProfiles.save({
...parsed.value,
id: found.profile.id,
createdBy: found.profile.createdBy,
createdAt: found.profile.createdAt,
updatedAt: Date.now(),
});
json(res, 200, { profile });
});
route('DELETE', '/api/lens-profiles/:id', async ({ req, res, params }) => {
const user = currentUser(req);
if (!user) return error(res, 401, 'Not signed in');
const found = editableProfile(params.id, user);
if (found.status) return error(res, found.status, found.message);
lensProfiles.remove(found.profile.id);
json(res, 200, { ok: true });
});
/**
* Store the original file. Raw files are demosaiced here so every browser can
* edit them; ordinary images are kept byte-for-byte and previewed client-side.