Is it possible to add personal lensfun data?

I have just received a new lens for my camera and I discovered that it is not present in lensfun.
I am calibrating it and I will share the resulting data with the lensfun project, like I have already done.
Since I have already done it I know that probably it will take a rather long time before I will find the data in the lensfun copy included in RT. I am sure that they will not be available in version 5.9, for example.
Moreover, I have calibrated the distortion of another lens with slightly different results than the lensfun ones. I prefer my calibration but there is no real reason to replace the official data with my result.

This will cause problems when I update RawTherapee. Of course I might manually edit the xml files, but that is not an optimal solution.

So here is the question: is it possible to create some lensfun files for my personal use, with data for a few lenses, so that those data will be used instead of the official lensfun ones, or if there is no lensfun entry?

Thanks in advance.

Fulvio Senore

Run the command lensfun-update-data as root and you will receive an update of the lensfun database. You never need to wait until a new RT version has the the new data you are looking for. If you can have a custom folder I don’t know. Sorry.

Yes, ~/.local/share/lensfun.

Thank you. Is it enough to create a file with only the few lenses that I calibrated or should I create a more complex file?

The new lens data should be enough.

To add user lens correction, perhaps have a look here Lens correction with modern cameras - #6 by jose-lens

Thank you, I will try as soon as the lens calibration will be done.

I have created a lens profile and I have submitted it to lensfun. In the meantime I would like to use it.
I copied the lens data into the relevant lensfun file in the RT installation and it worked: the lens is recognized.

Then I removed that data from the official lensfun file and I created a lensfun.xml file in the following folder:

C:\Users\Fulvio\AppData\Local\lensfun

but the lens is not recognized. I am using RT 5.8 on Windows 10.

The linked documentation states that a file loaded from lfDatabase::UserLocation will have the highest priority and it will override previously loaded profiles.
This location, for Windows, is defined as

%USERSPROFILE%/AppData/Local/lensfun

so it should be the folder where I have saved my lensfun.xml file.

BTW I noticed that there is a typo in the documentation: %USERSPROFILE% has no meaning in Windows, the correct spelling is %USERPROFILE%, but I don’t know if this can be the cause of the problem.

Does anybody have a suggestion to make a custom lensfun file work under Windows? Maybe RawTherapee is using a different folder?

Thanks in advance

I assume you still need the version folder for lensfun to find it. It should be version_1.

Thank you for your help.
I created the folder and I put a copy of the file in it, but it did not work.
The lens is still not recognized.

Open your RT options file, scroll down to the end of it, you’ll find this entry

[Lensfun]
DBDirectory={foobar}

If you change this entry, you have to close RT before changing it, else it will be overwritten when closing RT

And remember that the directory path will have to use Unix style “/”s rather than Windows style “\”s even on a windows machine.

Thank you for the suggestion. I tried it and it worked, but then I had no camera and I had only the lenses that I have profiled by myself.
It looks like this option sets the location of the lensfun database that will be used by the program.

Of course I can put a copy of lensfun in a folder and use this option, but this would not solve my problem completely.

I was looking for a way to add a personal lensfun file to an existing database, the one embedded in RawTherapee.
I have a profile for a lens that is different from the lensfun one. I cannot claim that it is better for general use so I would like to put it in a location with higher priority so that it will override the default profile.

The lensfun documentation states that this is possible but I have not been able to make it work under Windows.

@heckflosse can you link me to the part of build file where lensfun is built?