Add From metadata lens correction for Sony ARW and DNG - #1058
Draft
hsnilsson wants to merge 4 commits into
Draft
Conversation
hsnilsson
marked this pull request as draft
September 6, 2026 18:17
Owner
|
nice, I had quick scrollthrough and I have one suggestion: right now adding a new vendor (eg Fuji or Nikon) means touching few places. Consider giving RectilinearWarp/SonyWarp a common tiny protocol (has_distortion, has_ca, a remap(...) method) so a future CanonWarp is one new class + one new reader function, not three edited call sites. |
Contributor
Author
|
Hi, my agent pushed this without my permission and before I had time to actually work on it. Sorry for that, and thanks for great feedback - definitely makes sense to have a protocol. I hope to get some time tomorrow or at least within a few days to finish this. |
Keep Positive Source and embedded lens settings in the preview, cache and export paths. Add regression coverage for independent cache entries and worker forwarding. Validation: ruff format/check, ty check, and full pytest suite: 5479 passed, 26 skipped, 14 deselected.
Keep model capabilities and inverse maps in frozen warp classes. Use one file-reader registry, with shared TIFF traversal for Sony and DNG, so additional formats do not change metadata aggregation or rendering. Validation: 61 metadata tests passed; 32 image cases are pixel-identical to the previous implementation. Ruff and repository ty checks passed, with strict ty checks on the lens modules. Full suite: 5496 passed, 1 failed, 26 skipped, 14 deselected. The unchanged crosstalk profile test hit a same-mtime/size cache collision; reproduced separately, and all 17 profile tests passed on rerun.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Camera scans can contain lens-correction coefficients, but the Geometry panel only offers a manual radial coefficient. This adds From metadata beside Distortion Correction and shows the source and available distortion/lateral CA correction. Missing, identity, malformed, or unsupported data leave correction unavailable.
Only the mode is saved with the edit. Each source supplies its own coefficients, so copied settings and mixed batches cannot apply another file's lens profile. Enabling the mode replaces manual distortion; disabling it restores the manual slider.
Implementation
LensWarpdefineshas_distortion,has_ca, andremap(...). FrozenRectilinearWarpandSonyWarpclasses own their coordinate calculations. Metadata and rendering use the protocol without vendor-specific branches.Supported scope
Sony ARW distortion and red/blue CA tables, plus DNG WarpRectilinear (opcode 1, one or three planes). DNG 1.7 is supported when it carries this correction model. Lens identification and camera on/off flags alone do not enable correction; inherited Sony tags in converted DNG files are not applied.
WarpRectilinear2, fisheye, other/mixed opcode lists, composites, and RGB+IR sources remain unsupported. Choose the correction before crop/retouch. Edge sampling replicates boundary pixels. No Lensfun lookup is added.
Validation
test_saving_again_keeps_the_profile_in_its_own_file: a same-mtime/size TOML cache collision in code unchanged fromupstream/main. It was reproduced separately; all 17 crosstalk profile tests passed on rerun.uvbecause GNU Make is unavailable on this host.The user's Sony A7R V files have not been tested directly.
Implements the initial supported-format subset of #1057. Related to #1033 (external Lensfun profiles).