As you may have read in the Tools I use section, all my images are managed in Digikam.
I’ve been using it for several years, upgrading versions as they were released and at the time of writing this, I have about 40,000 images in its database.
Since a few releases, Digikam has introduced support of MySQL as a backend as an alternative to the SQLite embedded database. Digikam provides a migration wizard to switch from SQLite to MySQL but for some reason, I have never been able to successfully perform the migration and am still using SQLite.
This lead me to thinking that my Digikam database might have become inconsistent after having moved around so many images and thought it would be a good idea to write a tool to inspect the thousands of records in the database’s tables and figure out if they all make sense, if some might be missing, if some might be orphaned.
While all my other tools were written in bash, the complexity of this challenge made me chose Java. For you, it will be just as easy to use. No parameters are required as the tool will figure out the location of your Digikam database.
Digikam DB Validator
Report bugs to <email@example.com>Database Schema version is 5 – All tables will be validatedChecking AlbumRoots…OK
Checking Image Comments…OK
Checking Image Copyrights…OK
Checking Image Hashes…OK
Checking Image Informations…OK
Checking Image Metadata…OK
Checking Image Positions…OK
Checking Image Properties…OK
Checking Image Tags…OK
Building Tag Tree…OK
Checking TagsTree for completeness…OK
Checking TagsTree for orphaned entries…OKNo error found – Your Digikam database is integer
In this example, no errors were identified in the database and hopefully, that’s what you’ll get !
In my case, in the “Checking Images” item, the tool returned with 259 errors of the following type:
Image 33342 points to inexistiant Album 814 but similar image also found in album 1490
My guess is that there may have been a bug in one of the older versions of Digikam and when I had moved images to different albums, deleted albums or what not, some records in the database were not updated accordingly.
After looking at the entries in question, it seems those are all referring to some older pictures in my collection and none of these problems are recent so I’m confident that this was a bug that was fixed a while ago.
So what to do if the tool comes back with some errors ?!
Well, the tool won’t fix the database for you. This is something you’ll have to do manually … You can use the sqlite3 command line utility and issue SQL statements to look at the incriminated records and fix/delete them or you can use a graphical user interface like the SQLite Manager plugin for Firefox that I find very convenient !
At the moment this tool only support the SQLite backend, not MySQL. I’ll add MySQL support shortly.
Since I have not yet upgraded to Digikam 2.0, the tool only looks at the tables existing today in 1.9. All the new tables added with 2.0 are not analyzed. I’ll also add support for this soon.
The latest version of the tool and sources can be downloaded from the attachments section at the left of this page !
If you like this script, feel free to leave a comment !
If you run into problems, you can send me an email at firstname.lastname@example.org and I’ll help you out.
This software is licensed under the CC-GNU GPL version 2.0 or later.