Closed tvwerkhoven closed 2 years ago
Can you confirm whether lf_db_load_file
ignores entries if they already exist in the database? Meaning, it doesn't override them? I'm assuming the former, hence the issue, but would be good to have some reference for this.
Note that you can also disable loading of packaged lenses. Would that solve your issue?
lf_db_load_file
does not ignore, but overwrites existing entries. load_bundled=False
seems to work, but it's a bit inconvenient if you want to update just 1 lens.When adding a database file manually it's first in the list, e.g. after loading the db, the paths
list looks like:
['/opt/local/share/lensfun/version_1/slr-tamron.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/compact-canon.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/slr-samsung.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/slr-olympus.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/slr-nikon.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/compact-kodak.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/compact-sigma.xml',
'/Users/tim/Library/Python/3.8/lib/python/site-packages/lensfunpy/db_files/compact-ricoh.xml',
...
however, it seems the last file in the list is prioritised, as the extra lens parameters I added to my custom file disappeared.
load_bundled=False
seems to work, but it's a bit inconvenient if you have 1 lens to update because you need to load other files as well. E.g. I want to use vignetting info of Tamron SP 24-70mm f/2.8 Di VC USD (which is optically the same as the Pentax, hence my original question), so if I update slr-tamron.xml
with vignetting info. I'd prefer to load just that and rely on the rest of the db for other lenses/camera, else I would need to load all the other files I need as well.
I think changing the load order would fix this and provide a more user-friendly flow.
Looking at this in a bigger context, this is the current loading order, each overriding previous matching entries:
paths
argument (default is empty)load_bundled=True
(default is true)xml
argument (default empty)load_common=True
(default is true)It seems like a more sensible order would be:
load_bundled=True
(default is true)load_common=True
(default is true)paths
argument (default is empty)xml
argument (default empty)Agree, that makes sense.
A nice addition would be if paths
can be globbed as well, e.g. paths=['/opt/local/share/lensfun/version_1/*tamron.xml']
, similarly how load_bundled
uses glob.glob(xml_glob)
, but perhaps that should go in another issue ;)
I pushed a new version of lensfunpy with the loading order change, see https://github.com/letmaik/lensfunpy/releases/tag/v1.11.0. It'll be up on PyPI once https://github.com/letmaik/lensfunpy/actions/runs/2905440721 ran through.
In: https://github.com/letmaik/lensfunpy/blob/a16273a5488c9124cf5f035092cae031df213933/lensfunpy/_lensfun.pyx#L245
Propose to prioritise user-defined databases over packaged version. The former is most likely better.
From:
To: