Bug #8813

Lens is not correctly detected

Added by Torsten Bronger over 7 years ago. Updated over 5 years ago.

Start date:
Due date:
% Done:


Estimated time:
Affected Version:
hardware architecture:


If I load a JPEG, the lens given by Darktable is always "T-Mount Arax 35mm Tilt+Shift", which is not correct. In the module to correct lens distortions, I cannot select another lens. The EXIF data in the file is correct.

DSC02526.JPG (608 KB) DSC02526.JPG Original JPEG from the camera which exhibits the problem described in this issue. Torsten Bronger, 07/05/2012 03:19 PM

Related issues

Copied to darktable - Bug #10029: Lens is not correctly detected for new NEX (ILCE-6000)Fixed07/04/2012


#1 Updated by Simon Spannagel over 7 years ago

  • % Done changed from 0 to 20
  • Status changed from New to Incomplete

Hi Thomas,

in order to look into this (and hopefully solve) we definitely need a sample file.
Could you provide one of yours?


#2 Updated by Pascal de Bruijn over 7 years ago

In the future when reporting bugs please provide a bit more information. In this particular case camera make/model and your exact/full lens type would be the usual suspects (in addition to providing a sample).

From the little info we have now, I'm guessing you're using third party lens on your (Minolta/Sony) camera, is that correct?

Also, with EXIF problems please sure you have the latest version of Exiv2 (currently 0.23) installed, and Darktable built against that.

#3 Updated by Torsten Bronger over 7 years ago

The camera is a Sony NEX-7 with a native lens (SEL 18-55mm). Apparently, the lens ID is not set in the EXIF data (e.g. it is -1) which is erroneously interpreted by Darktable as "T-Mount Arax 35mm Tilt+Shift". The "lens model" field contains the corrent lens model name.

#4 Updated by Torsten Bronger over 7 years ago

I cannot manually change the lens in the "lens correction" module. Moreover, all settings in this module (geometry, scaling, TCA) have no effect. Is this related or should I file a separate bug report on this?

#5 Updated by Pascal de Bruijn over 7 years ago

  • Priority changed from Medium to Low
  • Status changed from Incomplete to Triaged

I'm guessing this is (at least partially) an Exiv2 problem, please report this to the Exiv2 project:

$ exiv2 -pt DSC02526.JPG | grep -i lens
Exif.Sony1.LensID Long 1 T-Mount | Arax MC 35mm F2.8 Tilt+Shift | Arax MC 80mm F2.8 Tilt+Shift | Zenitar MF 16mm F2.8 Fisheye M42 | Samyang 500mm Mirror F8.0 | Pentacon Auto 135mm F2.8 | Pentacon Auto 29mm F2.8 | Helios 44-2 58mm F2.0 | No Lens
Exif.Photo.LensSpecification Rational 4 180/10 550/10 35/10 56/10
Exif.Photo.LensModel Ascii 23 E 18-55mm F3.5-5.6 OSS

On my system I can manually select just fine. Please recheck using Darktable 1.0.5.

Also what might be a problem is an outdated version of the Lensfun library, and more particularly the lens database it includes.

At least for Ubuntu, my PPAs ship Lensfun 0.2.5, but it's lens database has been updated to a much more recent svn checkout to recognize more camera's and lenses.

But even with those updates, only your camera will be recognized. There are no correction profiles for Sony E lenses at all. So you'd have to calibrate your own lens and contribute the results to the lensfun project:

#6 Updated by Torsten Bronger over 7 years ago

Thanks for the links, I'll try to contribute to the lensfun project. However, I use Ubuntu 12.04 with lensfun 0.2.5.

Even with darktable 1.0.5, I cannot change the lens. I have to switch to another camera model first (e.g. Sony Alpha 100).

If Sony NEX is the selected camera (due to auto-detection), all settings in the "lens correction" module still have no effect. No TCA, no scaling, no geometry. I can change the settings but the RAW image remains the same.

This may be desired behaviour, I don't know. At least, this behaviour is confusing for the user in my opinion.

#7 Updated by Torsten Bronger over 7 years ago

I don't know what to report to the exiv2 project. "Exif.Photo.LensModel" contains the string that should be compared to the lens model in the lensfun database.

#8 Updated by Pascal de Bruijn over 7 years ago

Yes, but Exiv2 is reporting conflicting lens information which is odd at best.

You can report a bug about the fact that conflicting lens information is being provided. And possibly supply a link to this bug report. Then paste the link to the Exiv2 bug report here, so we can monitor the progress/comments.

#9 Updated by Torsten Bronger over 7 years ago

Sony's EXIF info says "65535" in Exif.Sony1.LensID (by the way, it uses the very same value for all lenses) but doesn't "Sony1" mean that it's proprietary and should not be parsed? I'm no EXIF expert, though.

#10 Updated by Pascal de Bruijn over 7 years ago

Sony1 does mean it's proprietary (like all MakerNotes), but that doesn't mean it shouldn't be parsed, as the MakerNote often container vital information.

Anyhow, I've filed a bug with Exiv2:

That said, I'll have a look what we can do from our end.

#11 Updated by Torsten Bronger over 7 years ago

(Sorry, I saw your follow-up only now.) Thank you for both, submitting the bug report and looking into possibilities of having a workaround in darktable.

#12 Updated by Wolfgang Kühnel over 7 years ago


as far as I can tell all the info neccessary to update exiv2
to fix this issue is here:
(This has been posted originally at

Although, I'm not sure if darktable code needs to be modified
to display "Lens Spec" tag instead of "LensID" info for Sony NEX bodies.


#13 Updated by Wolfgang Kühnel over 7 years ago

Could be that src/common/ lines 140...160 would be appropriate
to place a workaround for Sony NEX-es ?


#14 Updated by Wolfgang Kühnel over 7 years ago

  • Target version set to Candidate for next patch release

This is diff for /src/common/ as a simple trial how the issue can be solved:
< if(!strcmp(img->exif_model, "NEX-3")) sprintf(img->exif_lens, "(unknown)");

// FIXME: This is a ugly workaround
if(!strcmp(img->exif_model, "NEX-3")) {
sprintf(img->exif_lens, "(unknown)");
if ( (pos=exifData.findKey(Exiv2::ExifKey("Exif.Photo.LensModel")))
!= exifData.end() ) {
std::string str = pos->print(&exifData);
sprintf(img->exif_lens, str.c_str());

It's ugly but demonatrates OK how it can be done based on
the info published on

is a short screencast how this is tested with a directory that
contains 3 pairs of JPG and ARW pictures from a Sony NEX-3, taken with a
E16, a E18-55 and a manual lens.

#15 Updated by Pascal de Bruijn over 7 years ago

  • % Done changed from 20 to 100
  • Status changed from Triaged to Fixed

I've just committed your patch (with minor formatting adjustments):

Thanks for figuring this out and contributing!

#16 Updated by Torsten Bronger over 7 years ago

Tested and works for me, thank you!

#17 Updated by Cyril LEVIS over 5 years ago


I have the same problem with Sony Alpha 6000. His name is ILCE-6000 in exiv2 datas.

This is the what i have added and tested, its works. (based on Pascal de Bruijn patch)

    // workaround for an exiv2 bug writing random garbage into exif_lens for this camera:
    if(!strcmp(img->exif_model, "DMC-GH2")) snprintf(img->exif_lens, sizeof(img->exif_lens), "(unknown)");

    // Workaround for an issue on newer Sony new NEX cams.
    // The default EXIF field is not used by Sony to store lens data
    // FIXME: This is still a workaround
    if(!strncmp(img->exif_model, "ILCE", 4))
      snprintf(img->exif_lens, sizeof(img->exif_lens), "(unknown)");
      if ( (pos=exifData.findKey(Exiv2::ExifKey("Exif.Photo.LensModel"))) != exifData.end() && pos->size())
        std::string str = pos->print(&exifData);
        snprintf(img->exif_lens, sizeof(img->exif_lens), "%s", str.c_str());


#18 Updated by Cyril LEVIS over 5 years ago

  • Copied to Bug #10029: Lens is not correctly detected for new NEX (ILCE-6000) added

Also available in: Atom PDF

Go to top