Skip to content

LR-EDIT-OPTICS-PROFILE: Find a compact's built-in lens when the file names no lens (#3855) - #3868

Draft
endthestart wants to merge 1 commit into
storytold:mainfrom
endthestart:fix/3855-unnamed-built-in-lens
Draft

endthestart wants to merge 1 commit into
storytold:mainfrom
endthestart:fix/3855-unnamed-built-in-lens

Conversation

@endthestart

Copy link
Copy Markdown
Contributor

A PowerShot G7 X CR2 has no lens name and no lens specification, so the lens database lookup gave up before it looked at the camera. The database does have the lens. It's filed under the camera's own mount (canonG7X), which is how the existing built-in lens match already finds it for compacts that write a focal range as the lens name.

Now a file that names no lens falls back to its camera's built-in lens, and the library refresh picks up such photos that were imported earlier. I limited it to cameras whose mount name starts with a lower-case letter, which is how the lensfun data marks a fixed lens. Without that check a Pentax K-1 with an unnamed manual lens would have picked up the one Zeiss profile on its mount that has no "mm" in its name. If the mount has more than one profile (a converter variant, for example) the lens specification picks by focal range, and with no specification nothing is applied.

I added a test in lens_profiles.rs that fails on main, plus one in lensdb for the mount check and one for the refresh. I also ran the lookup on the CC0 G7 X sample from raw.pixls.us (CANON_G7X_IMG_6738.CR2) with lensfun's database and it finds "Canon G7 X & compatibles". Across that database 363 of 1059 cameras get a built-in lens this way and none of them is a body with a lens mount.

Let me know if you'd rather fix it another way. Thank you.

Fixes #3855

…names no lens (storytold#3855)

A PowerShot G7 X CR2 has no lens name or specification, so the lookup stopped before trying the camera's own mount.
Only fixed-lens cameras (lower-case mount names) get this fallback.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@juanlucer

Copy link
Copy Markdown

This PR (#3868) looks very similar to my issue.

My Canon PowerShot G7 X CR2 files also appear to contain camera information but no lens name, and LightCraft fails to match the Lensfun profile.

The description in #3868 seems to match the behaviour I'm seeing.

@DonPavlov

Copy link
Copy Markdown

This also fixes the Sony RX100 II (DSC-RX100M2): the ARW has no lens model, and lensfun lists the lens on mount sonyRX100II.

Only docs/parity-checklist.md and docs/whats-new.md conflict with main now, and keeping both sides resolves them. Could you rebase and mark it ready for review? I can open a PR against your branch if that helps.

Tested on current main with real ARWs: the profile is found and Lens Corrections switch on. At 10.4 mm the horizon's bow goes from about 20 px to 0.3 px (1500 px wide):

rx100ii-before-after

emmertex referenced this pull request in emmertex/chromaforge Nov 17, 2026
A fixed-lens camera's raw that names no lens and records no lens
specification (PowerShot G7 X CR2, RX100 II) now gets its camera's
built-in lens from the lens database, found by the camera's own mount.
find_built_in_lens now refuses a body (mount name starting with a capital,
lensfun's convention for interchangeable mounts). The Optics panel status
reports the found profile instead of "No lens named" for such photos.

Render change: only for those compacts with profile corrections on, where
a profile now applies.

Left out: upstream's cmd/lens_refresh.rs part; the fork has no library-wide
missing-profile refresh (lens.db.refresh re-reads the given ids).

Adapted from upstream #3868
Manual: develop/lens.mdx

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DonPavlov

DonPavlov commented Nov 17, 2026 •

Copy link
Copy Markdown

I rebased this onto current main and opened it as #4470, since this one is still a draft and conflicts with main. The code and your authorship are unchanged; only docs/parity-checklist.md and docs/whats-new.md needed resolving (your branch still had the compressed ORF row that main has since withdrawn, so I left that out). If you would rather keep this PR, take the rebased branch DonPavlov:fix/3855-rebased and I will close mine. Thank you for the fix.

@wanikhawar

Copy link
Copy Markdown
Contributor

#4470 carries this change forward, rebased onto current main with your authorship kept, and it also covers the file-has-a-specification-but-no-name case (RX100 II) and the refresh path. This draft conflicts with main, so it looks safe to close in favour of #4470.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Canon PowerShot G7 X not matched with Lensfun profile

4 participants