From be8cf3c88af89478ca1305d94a95f8dcf41e4720 Mon Sep 17 00:00:00 2001 From: Brian Hursey Date: Sat, 28 Nov 2026 16:21:19 +0000 Subject: [PATCH] Make lens-profile vignetting correction opt-in. Applying a profile used to enable distortion, CA and vignetting together, and the flat-field gain lifts the already tone-mapped corners above the frame centre, over-exposing the edges. Vignetting now defaults off when a profile is applied or restored from a camera default, and only turns on when a profile explicitly stored vignetting: true. --- src/components/Panels.tsx | 5 ++++- src/lib/edits.ts | 6 +++++- src/lib/import.ts | 5 ++++- src/lib/lensDefaults.test.ts | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/Panels.tsx b/src/components/Panels.tsx index 9b4d36a..65b7fc8 100644 --- a/src/components/Panels.tsx +++ b/src/components/Panels.tsx @@ -2028,7 +2028,10 @@ export function OpticsPanel({ model: result.model, crop: result.crop, cameraModel: photo.meta.camera ?? undefined, - corrections: { distortion: true, tca: true, vignetting: true }, + // Geometry and CA are safe to correct on their own; the vignetting gain + // lifts the corners above the frame centre, so it is left for the user to + // enable on the profile they applied. + corrections: { distortion: true, tca: true, vignetting: false }, distance: 1000, }; set({ lens: next }, 'Lens profile'); diff --git a/src/lib/edits.ts b/src/lib/edits.ts index 19434fd..d444440 100644 --- a/src/lib/edits.ts +++ b/src/lib/edits.ts @@ -421,7 +421,11 @@ function lensProfile(input: unknown): LensProfile | undefined { corrections: { distortion: corrections?.distortion !== false, tca: corrections?.tca !== false, - vignetting: corrections?.vignetting !== false, + // The vignetting map is a flat-field gain applied to the already + // tone-mapped proxy, which pushes the corners brighter than the frame + // centre and over-exposes the edges. It stays opt-in, so a profile saved + // without an explicit flag never brightens the corners. + vignetting: corrections?.vignetting === true, }, distance: num(raw.distance, 1000, 0.1, 100000), }; diff --git a/src/lib/import.ts b/src/lib/import.ts index 5ecedae..7348b16 100644 --- a/src/lib/import.ts +++ b/src/lib/import.ts @@ -85,7 +85,10 @@ function editsForImport(meta: PhotoMeta, defaults: CameraLensDefault[]) { if (match) { edits.lens = { ...match.profile, - corrections: { ...match.profile.corrections }, + // A saved default still carries whatever the profile had when it was + // stored. Applying it on import must not switch the vignetting gain back + // on and over-expose the corners, so that correction stays opt-in. + corrections: { ...match.profile.corrections, vignetting: false }, }; } return edits; diff --git a/src/lib/lensDefaults.test.ts b/src/lib/lensDefaults.test.ts index 4523282..5cf2f55 100644 --- a/src/lib/lensDefaults.test.ts +++ b/src/lib/lensDefaults.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; +import { normalizeEdits } from './edits'; import { defaultForMeta, type CameraLensDefault } from './lensDefaults'; import type { LensProfile } from '../types'; @@ -64,4 +65,20 @@ describe('camera-lens default selection', () => { ).toBe(newer); }); + it('leaves the vignetting correction off unless the profile asked for it', () => { + // Older saved profiles carry no corrections block at all; the flat-field + // gain would brighten the corners past the frame centre if it defaulted on. + const legacy = normalizeEdits({ lens: { maker: 'Nikon', model: 'Nikkor 50mm', crop: 1 } } as never); + expect(legacy.lens?.corrections).toEqual({ distortion: true, tca: true, vignetting: false }); + + const optedIn = normalizeEdits({ + lens: { + maker: 'Nikon', + model: 'Nikkor 50mm', + crop: 1, + corrections: { distortion: true, tca: true, vignetting: true }, + }, + } as never); + expect(optedIn.lens?.corrections.vignetting).toBe(true); + }); });