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:
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { normalizeEdits } from './edits';
|
||||
import { normalizeEdits, withoutLensVignetting } from './edits';
|
||||
import { defaultForMeta, type CameraLensDefault } from './lensDefaults';
|
||||
import type { LensProfile } from '../types';
|
||||
import type { LensProfile, PhotoRecord } from '../types';
|
||||
|
||||
const profile = (model: string): LensProfile => ({
|
||||
maker: 'Nikon',
|
||||
@@ -81,4 +81,31 @@ describe('camera-lens default selection', () => {
|
||||
} as never);
|
||||
expect(optedIn.lens?.corrections.vignetting).toBe(true);
|
||||
});
|
||||
|
||||
it('clears a stored vignetting flag once, in edits, snapshots and history', () => {
|
||||
const profile: LensProfile = {
|
||||
maker: 'Canon',
|
||||
model: 'EF 50mm',
|
||||
crop: 1,
|
||||
corrections: { distortion: true, tca: true, vignetting: true },
|
||||
};
|
||||
const photo = {
|
||||
id: 'p1',
|
||||
edits: { lens: profile },
|
||||
snapshots: [{ id: 's1', name: 'Before', ts: 1, edits: { lens: profile } }],
|
||||
history: [
|
||||
{ label: 'Import', ts: 1, edits: { lens: profile } },
|
||||
{ label: 'Exposure', ts: 2, edits: {} },
|
||||
],
|
||||
} as unknown as PhotoRecord;
|
||||
|
||||
const cleared = withoutLensVignetting(photo);
|
||||
expect(cleared?.edits.lens?.corrections.vignetting).toBe(false);
|
||||
expect(cleared?.snapshots?.[0].edits.lens?.corrections.vignetting).toBe(false);
|
||||
expect(cleared?.history?.[0].edits.lens?.corrections.vignetting).toBe(false);
|
||||
// Geometry and CA stay on: only the corner gain was the problem.
|
||||
expect(cleared?.edits.lens?.corrections.distortion).toBe(true);
|
||||
// Nothing left to do the second time, so the upgrade is idempotent.
|
||||
expect(withoutLensVignetting(cleared as PhotoRecord)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user