Apply the lens vignetting gain in linear light.
Lensfun's vignetting coefficients describe linear transmission, so multiplying them into the sRGB-encoded proxy brightened the corners far more than the lens had lost and over-exposed the edges. The gain now runs after the decode, in both the grade and the eyedropper. Existing records that stored the old auto-enabled flag are cleared once, on the server catalogue at boot and in the browser cache on its next IndexedDB upgrade, and the Optics panel says when the correction is off.
This commit is contained in:
@@ -281,6 +281,56 @@ if (!immichAlbumColumns.includes('kind')) {
|
||||
db.exec("ALTER TABLE immich_albums ADD COLUMN kind TEXT NOT NULL DEFAULT 'import'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Applying a lens profile used to enable its vignetting correction, and that
|
||||
* flat-field gain over-exposed the edges. The correction is opt-in now, so the
|
||||
* flag older edits stored is cleared once, here, before anything reads the
|
||||
* catalogue. Matching on the JSON text keeps the scan to the few rows that ever
|
||||
* carried it, and the rows it rewrites no longer match, so it is idempotent.
|
||||
*/
|
||||
const legacyVignetting = db
|
||||
.prepare(`SELECT id, data FROM photos WHERE instr(data, '"vignetting":true') > 0`)
|
||||
.all();
|
||||
if (legacyVignetting.length) {
|
||||
const updateData = db.prepare('UPDATE photos SET data = ?, updated_at = ? WHERE id = ?');
|
||||
const clear = (edits) => {
|
||||
const lens = edits && edits.lens;
|
||||
if (!lens || !lens.corrections || lens.corrections.vignetting !== true) return edits;
|
||||
return { ...edits, lens: { ...lens, corrections: { ...lens.corrections, vignetting: false } } };
|
||||
};
|
||||
let cleared = 0;
|
||||
for (const row of legacyVignetting) {
|
||||
let record;
|
||||
try {
|
||||
record = JSON.parse(row.data);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
if (!record || typeof record !== 'object') continue;
|
||||
let changed = false;
|
||||
const strip = (edits) => {
|
||||
const next = clear(edits);
|
||||
if (next !== edits) changed = true;
|
||||
return next;
|
||||
};
|
||||
record.edits = strip(record.edits);
|
||||
if (Array.isArray(record.snapshots)) {
|
||||
record.snapshots = record.snapshots.map((snap) =>
|
||||
snap && snap.edits ? { ...snap, edits: strip(snap.edits) } : snap,
|
||||
);
|
||||
}
|
||||
if (Array.isArray(record.history)) {
|
||||
record.history = record.history.map((entry) =>
|
||||
entry && entry.edits ? { ...entry, edits: strip(entry.edits) } : entry,
|
||||
);
|
||||
}
|
||||
if (!changed) continue;
|
||||
updateData.run(JSON.stringify(record), Date.now(), row.id);
|
||||
cleared += 1;
|
||||
}
|
||||
if (cleared) console.log(`lens vignetting: cleared the stored corner gain on ${cleared} photo(s)`);
|
||||
}
|
||||
|
||||
const q = {
|
||||
upsertEvent: db.prepare(`
|
||||
INSERT INTO events (id, owner_id, sort_index, created_at, data) VALUES (?, ?, ?, ?, ?)
|
||||
|
||||
Reference in New Issue
Block a user