Skip to content

Exif.NikonLd4.LensID favoured to Exif.Photo.LensModel, even if latter is defined in db and former is not #18665

Open
@blueglyph

Description

@blueglyph

Is there an existing issue for this?

  • I checked and did not find my issue in the already reported ones

Describe the bug

I created the lensfun calibration data for a 3rd-party lens, then I added that information in Darktable's share\lensfun\version_1\misc.xml file, but Darktable doesn't automatically recognize the lens when I open NEF raw files shot with that lens.

In the lens correction module, I see "253" as default (unknown) model, but the name corresponding to the model I've added is present in the drop-down list.

So I have either to select it manually for each photograph, or I can add the data in a .exiv2 (Linux) / exiv2.ini (Windows) file in my home folder. In that file, I have to put "253" (the LensIDNumber value) or "0" (the LensID value):

[nikon]
253=35mm f/2

If I convert the NEF into DNG, using the Adobe DNG Converter, Darktable automatically recognizes the model without requiring the .exiv2/exiv2.ini file, and it correctly shows the model in the Image Information panel, too.

I finally discovered that this strange behaviour was due to the way Darktable determines the lens model:

  • If it finds the Exif.NikonLd4.LensID (or LensIDNumber, that isn't clear) tag in the metadata, it uses the number as identifier, even if the model is defined in Exif.Photo.LensModel.
  • In the NEF, both tags are present, so Darktable takes Exif.NikonLd4.LensID and ignores Exif.Photo.LensModel. However, it doesn't find the numbers of the former, "0" or "253", in the database, so it gives up.
  • In the DNG, only Exif.Photo.LensModel is present, and the value is 35mm f/2. That's the model I added in the misc.xml file above, so it's automatically detected.

My problem with that, once the data on this 3rd-party lens in integrated into lensfun database and ultimately in a next version of Darktable, is that no other user will benefit from the detection. They'll either think it's not supported or will have to manually create the .exiv2 file (if they even know about it). More likely, they'll find it in the Voigtländer models and decide to select it manually each time.

Another problem is that it's impossible to distinguish a series of models using "0" and "253", like the 35 mm and 50 mm models from Voigtländer. Only Exif.Photo.LensModel can tell them apart.

=> Why doesn't Darktable falls back on Exif.Photo.LensModel if Exif.NikonLd4.LensID isn't in any database? Unless there's a way to link both data for all the impacted lenses and for everyone (without asking them to add files manually)? Perhaps if that value is "0", or if Exif.NikonLd4.LensIDNumber is "253", then it should look at the Exif.Photo.LensModel value?

XML content of the calibrated lens

    <lens>
        <maker>Voigtländer</maker>
        <model>35mm f/2</model>
        <model lang="en">APO-LANTHAR 35mm F2 Aspherical II</model>
        <mount>Nikon Z</mount>
        <cropfactor>1</cropfactor>
        <calibration>
            <!-- Taken with Nikon Z6III -->
            <distortion model="ptlens" focal="35" a="0.00726" b="-0.01914" c="0.0101"/>
            <tca model="poly3" focal="35.0" vr="1.0000325" vb="0.9999729" />
            <vignetting model="pa" focal="35.0" aperture="2.0" distance="0.27" k1="-1.7274801" k2="1.4821616" k3="-0.5357087" />
            <vignetting model="pa" focal="35.0" aperture="2.0" distance="0.54" k1="-2.1529816" k2="2.1936554" k3="-0.8936036" />
            <vignetting model="pa" focal="35.0" aperture="2.0" distance="1.62" k1="-2.3381563" k2="2.5067040" k3="-1.0497600" />
            <vignetting model="pa" focal="35.0" aperture="2.0" distance="1000" k1="-2.4054764" k2="2.6108750" k3="-1.0973622" />
            <vignetting model="pa" focal="35.0" aperture="2.8" distance="0.27" k1="-0.4931862" k2="-0.3903400" k3="0.2860779" />
            <vignetting model="pa" focal="35.0" aperture="2.8" distance="0.54" k1="-0.5818163" k2="-0.5645652" k3="0.4422908" />
            <vignetting model="pa" focal="35.0" aperture="2.8" distance="1.62" k1="-0.6329567" k2="-0.6647739" k3="0.5480756" />
            <vignetting model="pa" focal="35.0" aperture="2.8" distance="1000" k1="-0.6536585" k2="-0.7188463" k3="0.6043772" />
            <vignetting model="pa" focal="35.0" aperture="4.0" distance="0.27" k1="-0.5839239" k2="0.0348811" k3="0.0656375" />
            <vignetting model="pa" focal="35.0" aperture="4.0" distance="0.54" k1="-0.7391125" k2="0.1372117" k3="0.0234026" />
            <vignetting model="pa" focal="35.0" aperture="4.0" distance="1.62" k1="-0.8256081" k2="0.2102259" k3="-0.0122386" />
            <vignetting model="pa" focal="35.0" aperture="4.0" distance="1000" k1="-0.8589557" k2="0.2228163" k3="-0.0119729" />
            <vignetting model="pa" focal="35.0" aperture="5.6" distance="0.27" k1="-0.5812536" k2="0.0279456" k3="0.0705040" />
            <vignetting model="pa" focal="35.0" aperture="5.6" distance="0.54" k1="-0.7175983" k2="0.0628979" k3="0.0875625" />
            <vignetting model="pa" focal="35.0" aperture="5.6" distance="1.62" k1="-0.7939760" k2="0.0946543" k3="0.0903589" />
            <vignetting model="pa" focal="35.0" aperture="5.6" distance="1000" k1="-0.8303944" k2="0.1121402" k3="0.0904709" />
            <vignetting model="pa" focal="35.0" aperture="16.0" distance="0.27" k1="-0.6030442" k2="0.0509183" k3="0.0586593" />
            <vignetting model="pa" focal="35.0" aperture="16.0" distance="0.54" k1="-0.7165359" k2="0.0224849" k3="0.1161671" />
            <vignetting model="pa" focal="35.0" aperture="16.0" distance="1.62" k1="-0.7985310" k2="0.0598960" k3="0.1186587" />
            <vignetting model="pa" focal="35.0" aperture="16.0" distance="1000" k1="-0.8312505" k2="0.0598966" k3="0.1325040" />
         </calibration>
    </lens>

Sample image

I can't upload it here, so I temporarily hosted it here.

Exiv2 information

DSC_1956.NEF:
Exif.NikonLd4.LensID                         Short       1  0
Exif.Photo.LensModel                         Ascii      65  35mm f/2

DSC_1956.DNG:
Exif.Photo.LensModel                         Ascii       9  35mm f/2

Steps to reproduce

  1. Remove any information related to the lens model from the .exiv2 / exiv2.ini file in the home directory

  2. Add the information about the lens model into Darktable's share\lensfun\version_1\misc.xml file

  3. Load a NEF photo taken with that model lens
    => Darktable fails to recognize the model automatically

  4. Convert the NEF to DNG

  5. Load the DNG
    => Darktable successfully recognizes the model automatically

  6. Extract the exiv2 Exif.NikonLd4.LensID information from the NEF file (or Exif.NikonLd4.LensIDNumber)

  7. Add the information into the .exiv2 / exiv2.ini file

  8. Refresh the metadata EXIF information in Darktable lighttable mode

  9. Try step 3 again=> Darktable successfully recognizes the model automatically

Expected behavior

No response

Logfile | Screenshot | Screencast

No response

Commit

No response

Where did you obtain darktable from?

darktable.org / GitHub release

darktable version

5.0.1

What OS are you using?

Windows

What is the version of your OS?

Windows 10 x64 22H2

Describe your system

No response

Are you using OpenCL GPU in darktable?

Yes

If yes, what is the GPU card and driver?

No response

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: DAMmanaging files, collections, archiving, metadata, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions