Metadata for “manual” lenses

Hi,
I occasionally use some vintage lenses, which don’t have any electronics and don’t supply any data to camera’s software. Olympus cameras (and probably most other) allow to create entries with Lens name, Focal distance and Aperture and then choose that setting when using the lens. Lens name then can be found in the metadata of RAW as, for example:

0xa434 Photo  LensModel  Ascii 32  Miida 135mm 1:2.8

0xa434 Photo  LensModel  Ascii 32  OM-System Zuiko MC Auto-T 135mm

Focal distance and Aperture (F Number) also appear in metadata. All are present in JPG exported from darktable. Also all are automatically used when, for example, uploaded to Flickr. However darktable interface doesn’t show the Lens name –

dt_metadata_Screen_20240725_202546

– as it is relying on other Exif field(s) for lens ID. In case of Olympust it may be Exif.OlympusEq.LensType.

May not be a huge issue, but sometimes it is. For instance, when comparing images taken with two 135mm/2.8 vintage lenses (Miida and OM Zuiko) the image info in darktable is identical. So then, in darktable, it’s hard to tell which lens was used for that particular image.

Has anyone run into similar situation? Any ways to make info from Photo.LensModel field visible somewhere?

1 Like

You could use a lua script and exiftool to get the data from the raw and populate the database fields.

1 Like

Same here. Exif tags are a science of its own. I use very often manual lenses. They do not supply any exif data to the raw files.
Before importing into dt, I run a script with which exiftool writes the required data into the raw files. In my opinion, there are several lens tags in a raw file. You need to write the right tag for dt.

LModelNeu="Voigtländer Heliar Classic 50mm f1.5 VM"
LMakeNeu="Cosina/Voigtländer"
LInfoNeu="50mm f/1.5"
MaxApNeu="1.5"

for thefile in *DNG; do
    exiftool -q -q -m -LensModel="$LModelNeu" $myfile \
    -LensMake="$LMakeNeu" $thefile \
    -LensInfo="$LinfoNeu" $thefile -MaxApertureValue="$MaxApNeu" $thefile  "-FileModifyDate<DateTimeOriginal" "-FileModifyDate<CreateDate" $thefile \
    -FLength=50.0mm \
    -FocalLength=50.0mm -Lens=50.0mm -minFocalLength=50 -maxFocalLength=50  $thefile
done

2 Likes

I don’t mind modifying RAW (there are unmodified original copies anyway) and I actually tried writing into LensModel tag, but the ‘lens’ still remains ‘None’ in darktable’s ‘image information’. Using darktable 4.8 though, not git current…

you have to select the image then use the refresh EXIF data in the actions on selected images module

Yes, I did try that, with no change. Though in a testing setup like this I usually just delete ~/.config/darktable/, then all .xmp and import anew…

Did you write into LensModel or Lens Model tag. Dumping EXIF data from images shows the Lens Model tag

1 Like

This may explain it. darktable/src/common/exif.cc:

   else if(FIND_EXIF_TAG("Exif.OlympusEq.LensType"))
    {
      // For every Olympus camera Exif.OlympusEq.LensType is present.
      _strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);

      // We have to check if Exif.OlympusEq.LensType has been translated by
      // Exiv2. If it hasn't, fall back to Exif.OlympusEq.LensModel.
      std::string lens(img->exif_lens);
      if(std::string::npos == lens.find_first_not_of(" 1234567890"))
      {
        // Exif.OlympusEq.LensType contains only digits and spaces.
        // This means that Exiv2 couldn't convert it to human readable form.
        if(FIND_EXIF_TAG("Exif.OlympusEq.LensModel"))
        {
          _strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
        }
 ... ... ...

With no data from the lens firmware, OM puts 0 0 0 0 0 0 into Lens Type tag, which is interpreted as None by Exiv2 and the if(std::string::npos == lens.find_first_not_of(" 1234567890")) doesn’t match and LensModel is not used…

Did anything happen with this topic?

I have a Pen-F (9+ years old) and an OM-3 (new in 2025). Both have a “Lens Info Settings” Dialog, where I can enter and select lens descriptions. The goal should be, to get this data into darktable for image information and lens correction.

The old code is from 2015. It assumes numbers and spaces in Exif.OlympusEq.LensType in case of manual lenses, which exiv2 probably did at that time. But now, as sugarbravo said, it says “None”. So the old code probably currently doesn’t work for anybody.

Exif.OlympusEq.LensModel contains the data from “Lens Info Settings” Dialog only for pictures from the Pen-F, but not from the OM-3. The data shows up on both cameras in Exif.Photo.LensModel.

The question is, whether in other Olympus cameras, presumably older than the Pen-F, Exif.Photo.LensModel would not give the expected data.

This can be tested with the exiv2 command line utility:

> exiv2 -Ph -g "Exif.Photo.LensModel"  <your filename here>
 0000  54 54 41 72 74 69 73 61 6e 20 37 2e 35 6d 6d 00  TTArtisan 7.5mm.
 0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

If the field is empty, you get a block of zeros. If it does not exist, exiv2 returns with an error.

Based on this, I have modified and cleaned up the code to:

    else if(FIND_EXIF_TAG("Exif.OlympusEq.LensType"))
    {
      _strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
    
      // We have to check for the special case "None", which is used for manual lenses
      if(!strncmp(img->exif_lens, "None", 4))
      {
        // The data from the in camera "Lens Info Settings" Dialog can be found in
        // Exif.Photo.LensModel
        if(FIND_EXIF_TAG("Exif.Photo.LensModel"))
        {
          _strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
        }
      }
    }

Which works for my cases.

Olympus and now OM System put 0 0 0 0 0 0 into OlympusEq.LensType when lens does not communicate electronically its model. User-entered string goes into Photo.LensModel. For example from OM-3:

$ exiv2 -pv *ORF|grep Lens
0x0201 OlympusEq    LensType                    Byte        6  0 0 0 0 0 0
… … …
0xa434 Photo        LensModel                   Ascii      32  OM System Zuiko MC Auto-W 24/2

Exiv2 decided to interpret 0 0 0 0 0 0 as localised None:

$ exiv2 -pt *ORF|grep Lens
Exif.OlympusEq.LensType                      Byte        6  None

So your patch will work on a system with English locale.

A proper fix would be to (for Olympus/OM System) to retrieve uninterpreted value of OlympusEq.LensType. If it’s 0 0 0 0 0 0, then to check whether there maybe is a lens name in Photo.LensModel and, if yes, use that for image information > lens.

Ok, at first glance in the exiv2 code it looks like you say. But: I am on a german system and this string is not translated, although it is in the po-file. Even stranger (keine is the german translation for None):

> exiv2 -g "Exif.OlympusEq" p3250063.orf
...
Exif.OlympusEq.LensType                      Byte        6  None
...
Exif.OlympusEq.Extender                      Byte        6  None
...
Exif.OlympusEq.FlashType                     Short       1  Keine
Exif.OlympusEq.FlashModel                    Short       1  Keine

For some labels, the value is translated, for others not. For LensType the None is in the code like this: N_("None"). All translatable strings are coded like this. N_ is a macro which is resolved to

#define N_(String) String

Whether the string is actually translated is decided in the tag specific print-function. And for OlympusEq.LensType it is not.

I would have expected it to be returned as Keine in German locale. If it is not, then is it a bug or intentional? How would returning None in non-English be more helpful, than 0 0 0 0 0 0? Can this behavior of exiv2 be relied on?..

It is definitely not a bug, but whether it is intentional or just to remove a special case and make the code shorter is hard to say. As I showed, it is not a single place in the code where this happens.

It is more helpful because the primary use case for exiv2 is as library. I think about asking them to completely remove this N_(…) and put a comment there, that this is part of their API and should never be localized. Their top goal for the future is “A stable API”.

Ah, I just see, that you have already filed a pull request there. Which is stuck. You did not know, that this string is actually not localized. My proposal to remove this N_(…) would not change the behavior of exiv2, it would only make it clear in the source code, that this string just should never be localized.

This is much easier to decide.

The darktable code has to be changed anyway, because after detecting the 0 0 0 0 0 0 the current fallback is Exif.OlympusEq.LensModel. It would be found, but is empty on newer cameras, so the code would never try Exif.Photo.LensModel.

Hello,

After reading this discussion, I conclude that at this moment (in DT 5.0.1) there is no way to make manual lenses recognizable in Darktable, if an image was taken with Olympus camera (e.g. an old E-PL8). Is that correct?

Also the issue seems to fixed by @Arnd and it will be deployed in next version of DT?

Yes.

I add info to ORF files with

exiv2 -m cmd.txt file.ORF

where cmd.txt is, for example:

add Exif.OlympusEq.MinFocalLength                Short      50
add Exif.OlympusEq.MaxFocalLength                Short      50
add Exif.OlympusEq.LensModel                     Ascii      OM System Zuiko Auto-S 50mm 1:1,2
set Exif.Photo.LensModel                         Ascii      OM System Zuiko Auto-S 50mm 1:1,2
set Exif.Photo.Lens                              Ascii      OM-System Zuiko Auto-S 50mm 1:1,2
set Exif.Photo.LensMake                          Ascii      Olympus
set Exif.Photo.MaxApertureValue                  Rational   12/10
set Exif.Photo.FocalLength                       Rational   50/1
set Exif.Photo.LensSpecification                 Rational   50/1 12/10
set Exif.OlympusEq.LensSerialNumber              Ascii      1120849

Some people will advise to never-ever modify RAW files, but …it’s my files. And I can always keep unmodified copies, if I want to.

As for the fix, the one used by @Arnd seems to work. But it may not be the best way around this issue. Olympus puts 0 into Lenstype, when the lens does not supply its ID electronically. Exiv2 interprets that into “None,” localised. For whatever reason, the string is not always localised. That’s why the fix works. It may be more reliabale to check for the uninterpreted value of Lenstype (0 or not).

But perhaps Photo.LensModel field is even more useful? It is always populated: either by electronic lens’ automatically supplied data or by user’s custom entry in camera settings. Moreover, Photo.LensModel may even give more accurate data, than LensType. For example, using the OM System 12-40/2,8, exiv2 -pt…:

OlympusEq.LensType Olympus M.Zuiko Digital ED 12-40mm F2.8 Pro
Photo.LensModel    OM 12-40mm F2.8 II

Due to the reuse of lens ID, exiv2 interprets the new Mk.II lens as the original 12-40. Perhaps OMDS reused the lens ID because the two lenses are optically identical, or maybe not…

1 Like

Good news: with the help of developer kmilos we got the feature merged:

It now actually checks for the binary 0 0 0 0 0 0
It’s planned for 5.2

Good news, indeed. Thanks for the patch to darktable.