[Fwd: captions gone but still exist in digikam4.db]

Andrey Goreev aegoreev at gmail.com
Thu Jan 12 17:11:05 GMT 2017


What a hassle. I am glad you managed to restore the data.
Thank you for sharing the solution. I saved this to my Google Keep just in
case.

Best regards,
Andrey Goreev

On Wed, Jan 11, 2017 at 11:42 AM, Jim Gomi <gomi at mailup.net> wrote:

> I have sorted out what the problem was: my digikam4.db database became
> corrupted, probably because I restored from an rsync backup, and I
> ended up with two entries in digikam4.db for each image.
>
> For each image, one of the entries had the correct metadata (caption
> etc) but didn't know which album the image belonged in.
> The other entry associated the image with the correct album, but didn't
> have the right metadata.
>
> I fixed the problem by writing a python code that went through all the
> JPG files in my collection, and for each file it found the relevant
> entries in the digikam4.db database, extracted the caption, and wrote
> it to the file using exiv2.
>
> Then I deleted the database and restarted digikam.
> Digikam read the captions from the metadata of the JPG files and
> recreated a correct database.
>
> In future, I will always configure digikam to store metadata in the JPG
> files as well as in the database.
>
>
>
> The core elements of the python code are:
>
> import sqlite3
> digikam_home='/where/photos/live'
> db = sqlite3.connect(os.path.join(digikam_home,'digikam4.db'))
> cursor = db.cursor()
> filename='IMG_2002.JPG'   # for example
> cursor.execute('''SELECT id FROM Images WHERE name=?''', (filename,))
> imageid_tuple_list=cursor.fetchall()
>
> # Now with  an imageid one can extract the caption:
> imageid=imageid_tuple_list[0][0]
> cursor.execute('''SELECT comment FROM ImageComments WHERE imageid=?''',
> (imageid,))
> comment_tuple_list=cursor.fetchall()
>
>
>
>
>
> -------- Forwarded Message --------
> From: Jim Gomi <gomi at mailup.net>
> Reply-to: digiKam - Home Manage your photographs as a professional with
> the
>  power of open source <digikam-users at kde.org>
> To: digikam-users at kde.org
> Subject: captions gone but still exist in digikam4.db
> Date: Mon, 26 Dec 2016 00:18:35 +0000
>
> The captions have disappeared from a bunch of my photos.
>
> However, when I browse the digikam4.db file using an SQLite browser, I
> can still find, in the ImageComments field, the text that was
> originally in one of the disappeared captions.
>
> Does anyone have any suggestions about what might be going on, and how
> to get the captions back?
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/digikam-users/attachments/20170112/95d51501/attachment.html>


More information about the Digikam-users mailing list