Hi, thanks for this excellent module which has already saved me loads of time.
Opening my Digikam database (digikam4.db) with sqliteman, I can see that the images table includes previously-deleted image files, with status set to 3 and album to null. These rows are included in lists returned by dk.images.all(). So for example, executing this code when some image files tagged with My tag have previously been updated will throw an AttributeError when the iteration reaches the first 'deleted' image:
dk = Digikam('digikamrc')
my_images = dk.tags['My tag'].images.all()
for i in my_images:
path_to_image = i.abspath
throws
Traceback (most recent call last):
File "<...>/test_ddb.py", line 17, in
path_to_image = i.abspath
^^^^^^^^^
File "<...>/.venv/lib64/python3.11/site-packages/digikamdb/images.py", line 444, in abspath
self.album.abspath,
^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'abspath'
Should there be something like an include-deleted (default = False) arg in the images.all() method to filter out these rows? Or specifically in the abspath call, a test for a null album attribute? In the meantime an easy workaround is to use
my_images = [i for i in dk.tags['My tag'].images if i.album]
instead of images.all()
Hope this makes sense
Hi, thanks for this excellent module which has already saved me loads of time.
Opening my Digikam database (
digikam4.db) withsqliteman, I can see that theimagestable includes previously-deleted image files, withstatusset to 3 andalbumto null. These rows are included in lists returned bydk.images.all(). So for example, executing this code when some image files tagged withMy taghave previously been updated will throw anAttributeErrorwhen the iteration reaches the first 'deleted' image:dk = Digikam('digikamrc')my_images = dk.tags['My tag'].images.all()for i in my_images:path_to_image = i.abspaththrows
Should there be something like an
include-deleted(default =False) arg in theimages.all()method to filter out these rows? Or specifically in theabspathcall, a test for a nullalbumattribute? In the meantime an easy workaround is to usemy_images = [i for i in dk.tags['My tag'].images if i.album]instead of
images.all()Hope this makes sense