Skip to content

[Feature] From metadata lens correction for embedded distortion and lateral CA data #1057

Description

@hsnilsson

Problem

When camera-scanning film, I would like NegPy to use supported lens-correction data embedded in the source file instead of requiring manual adjustment. The current Geometry UI exposes a manual Distortion Correction slider backed by distortion_k1.

Proposed behavior

Add a From metadata button/toggle next to Distortion Correction (or in a Lens Corrections section):

  • Make it clickable only when the current source contains supported, usable embedded correction data. Otherwise keep it disabled with a reason, such as no embedded correction data or unsupported metadata format.
  • Clicking it explicitly enables the available correction; detecting metadata should not silently apply it. Show which corrections are available and active.
  • Distinguish geometric distortion (barrel/pincushion) from lateral chromatic aberration (RGB channel misalignment/color fringes). If usable data exists for only one, enable only that correction. CA-only metadata must not enable geometric distortion correction. Separate toggles under a shared Lens Corrections section would make this clear.
  • A lens name, focal length, or a camera correction on/off flag alone is not an embedded correction model. Supported DNG correction opcodes or supported manufacturer correction coefficients could qualify, subject to format support and validation.
  • Use the scanning camera/lens metadata from the source, not archival metadata describing the original film camera/lens. This cannot generally remove aberrations already recorded on the film, and is not a general fix for longitudinal CA.
  • Preserve manual correction as a fallback and make its interaction with metadata mode explicit to avoid accidentally stacking the same correction. Avoid reapplying corrections already baked into decoded pixels where this can be determined.
  • Save the selected mode with the edit and keep preview/export consistent. In a batch or when copying settings, resolve availability and coefficients separately for each source rather than copying another image's lens coefficients.

Scope / relationship to existing request

Related to #1033, which proposes Lensfun database support. This request specifically concerns embedded correction data and a metadata-aware UI. Looking up an external Lensfun profile using EXIF lens identification is a useful complementary path, but should be identified as profile-based correction rather than embedded correction data. These could share an implementation/UI if preferred.

An initial version could support a documented subset of metadata formats, keeping unsupported cases disabled. No sample RAW file has been validated for this request, so it does not assume every camera embeds usable coefficients.

Acceptance examples

  • Supported distortion data: From metadata is available and produces matching preview/export geometry.
  • Supported lateral-CA data only: CA correction is available; distortion remains unavailable.
  • Lens-identification EXIF only, absent data, or unsupported/malformed data: embedded correction stays disabled with an explanation; manual correction remains usable.
  • Switching files or processing a mixed batch does not reuse coefficients from a different source; reopening an edit restores the chosen mode.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions