add lens information in darktable

Hi all,

Is there a canonical way of adding lens information in darktable? I’m not talking about lens correction and such, I would simply like to add basic lens information, if the lens is not included in the lensfun database.

Thanks,

1 Like

Hi and welcome!

Is the lens electronic and add metadata to your raw file? If yes, you can use the exiv2 config file to map the metadata number onto a human readable name.

If you lens does not add metadata to your raw file, like vintage lenses, then I’d suggest using a tag to store the data.

2 Likes

I believe there are some recent threads on the same topic. Try to search for those, as they probably have the answer.

1 Like

No, the lenses I’m talking about are not electronic, that’s the problem. I add tags, as you suggested, but I have an issue with that approach. Namely, darktable allows filtering of collections by lens, focal length and aperture. If I add all these in tags, then half of the pictures must be filtered through tags, the other half through the standard.

Before posting, I searched the threads. :wink: Most are related to incorrectly identified lenses, lens distortion corrections and the like. I’m really after being able to insert lens data manually.

Basically, what I’d like to have is pretty similar to adding geographical coordinates: you can do that in darktable in the map tab, and you can even override the coordinates, if your camera had a GPS receiver, and records those in the exif data.

2 Likes

I would use exiftool from command line before import. E.g. I use “TS-E50mm f/2.8L MACRO” lens, and if information was not saved automatically I would add it with command:

exiftool -LensModel="TS-E50mm f/2.8L MACRO" -FNumber="5.6" image.CR3

There might also be other tags describing lens and other basic information.

Please test it carefully if these were the correct tags for the file types your camera uses. These can be added into RAW images. If you write these to RAW files, make sure that you have also a copy without these added. Exiftool might break something with those files and if that happens, maybe you can’t open them in the future.

Unfortunately I don’t know how to set this information directly from darktable. Maybe with some LUA scripts can use exiftool?

2 Likes

Many thanks, Marko, for the suggestion! Calling exiftool via Lua is also a great idea.

2 Likes

You can use exiftool to write to xmp files directly: Metadata Sidecar Files

1 Like

With that, I can write the extra EXIF information in the sidecar file, but that’s still not taken into account by darktable, so it doesn’t solve the original problem. However, if darktable could be made to take some EXIF data from the sidecar file, then this would definitely be an acceptable solution.

Then you’re not writing the right tag, there are quite a few different ones and they vary by manufacturer.

Try Digikam. Nice gui for exiftool.

There doesn’t appear to be a way to specify the actual lens, only focal length and such.
image

jExifToolGUI can do it, but can only save to the original file, not xmp sidecars:
image

1 Like

Are you saying that tags written to the sidecar are treated on the same footing as tags in the raw file?

Writing the information to the sidecar file will not work unless you import the image again, in which case the information from the sidecar will be applied.

The smart way to do this is with a Lua script that takes a text string (the lens information) and writes it to the database for the selected images.

No raw files need to be modified. No convoluted exercises (using the XMP) need to be done. And, if it all gets messed up, you simply reset the EXIF information and try again.

That would be acceptable, I think.

Is there such a script already? I came here because I have a similar issue: the camera I use does not write the lens information in exif and I do not want to overwrite the raw file.

I guess I dropped the ball on this. I should have something in a few hours.

1 Like

Here’s the first cut at a script that will do it. Unzip it and drop it into your lua scripts contrib directory. Start it with script manager and it will create a module in the right panel. Add lens names, then change to select lens name and choose the one to apply. Select the images and either use the button in the module or the button in the actions on selected images module to apply the new lens name. You can also assign a shortcut to apply the selected name and then just hover over an image and hit the shortcut.

Still need a way to edit and delete lens names.

add_lens_info.zip (3.1 KB)

Nice, thanks! I’ll test it when I’m in front of my workstation again!
Would it be an option to recycle the lens selection from the lensfun database, i.e. lens correction module?