HOWTO: digiKam display Darktable thumbnails

Yes! It’s true, you can now see your Darktable edits in the digiKam thumbnail/icon views.

If you’re like me, you love the power of digiKam’s asset management features like advanced search, AI face tagging, heirarchical tagging, geolocation, metadata templates, Lighttable culling, and more (yes, I know Darktable has many of these features, but not to the level of digiKam). Personally, I think digiKam is the best open-source DAM, and one of the best overall (I’ll admit I’m biased). I also think Darktable is an absolutely fantastic RAW editor, but the DAM aspect of Darktable I always thought was a little basic. Please don’t misunderstand me, I love both programs and I use them both every day.

The one thing that has really frustrated me was I had to save my Darktable edits to JPG or some other file to see them in digiKam. Well, no longer! Thanks to our lead dev on the digiKam team, he pointed me to a feature in that’s been in digiKam for years, but never really used: The ability to read a thumbnail from an .xmp sidecar.

I created a Darktable Lua script that writes a 200x200 thumbnail to the .xmp sidecar where digiKam can read it and use it to show the Darktable edits in all the digiKam thumbnail/icon views.

Caution: This is still very early in development and highly experimental, but I’ve been using it for a few months. It works well enough for now. There aren’t any functions that will affect the base image.

You can get all the details in the github repo here: Darktable-digiKam Thumbnails

I’m hoping some people more experienced with Darktable Lua will help me develop this further with a Darktable UI and button. See the repo Readme.md for the development plan.

Note: This SIGNIFICANTLY increases the size of the .xmp file, but I think the functionality it delivers is well worth it. Also, you don’t need to write every thumbnail to the .xmp; only the ones you want to see in digiKam.

6 Likes

@Michmill, A great thank you for developing and sharing this functionality between DT and DK. I have hoped for something like this to surface that bridges these two programs.

I was able to install all the bits and pieces into my environment: Fedora 41 & digiKam 8.5.0 & darktable 5.0.1.

The darktable side works. A thumbnail is written into the xmp file. However I can’t get digikam to read the thumbnail from the xmp (the metadata settings are set and the Album reread xmp is issued).

An unpleasant and undesired observation is the purging of all the darktable edits from a file having embedded digikam thumbnail information. This can be observed, if I open the file from the digiKam side with ‘Open with > darktable’ functionality.

Same observations also with digiKam 8.0.6 that landed on my computer a few minutes ago.

Hi @kaizubg,
Thank you for the information. I’ll try to recreate the issues today. I have a few ideas, though.

Can you send me a copy of the .xmp file so I can verify everything was written properly?

  • Did you update your dartablerc file to change the database to :MEMORY:?
  • In Darktable Preferences->Storage, what is the auto-save interval? Maybe try setting it something small like 2 or 3 seconds.
  • Did you edit the image after you saved the thumbnail? Saving the thumbnail has to be the last thing you do before exiting Darktable.
  • Did you save the thumbnail from the lighttable or darkroom view? The thumbnail should be saved from the lighttable view because changing from the darkroom to lighttable view saves all the edits.

Cheers,
Mike

Hi,

Here are two XMP’s
DSCN9367_#2.NRW.xmp (64.0 KB)
DSCN9367_#3.NRW.xmp (18.5 KB)

#2 is written from darktable (no other edits after closing)
#3 is what is left after opening the same file from digikam (& closed in darktable)

  • darktablerc database parameter was originally not set; set now - no effect
  • storage autosave interval was orginally 10; set now to 3 - no effect
  • no edits; wrote thumbnail as last step before closing
  • Lighttable view

Best, Kai

#3 still seems to have the (or at least some) edit information, the thumbnail is missing though.
Not sure if that behaviour is correct (if not, it looks like a bug in digikam, not darktable)

Also, the thumbnail uses a tag in the “digikam” namespace, but that namespace is not declared
(with xmlns:digiKam="http://www.digikam.org/ns/1.0/", as taken from a digikam-generated sidecar).

Hi @kaizubg,
Thanks for sending the XMP samples. Those are very interesting. First, @rvietor is right. The first thing I see, or more precisely, don’t see in both samples are missing several namespaces.

Here’s an example of what I see on my system:
<rdf:Description rdf:about=“”
xmlns:MicrosoftPhoto=“http://ns.microsoft.com/photo/1.0/
xmlns:acdsee=“http://ns.acdsee.com/iptc/1.0/
xmlns:aux=“http://ns.adobe.com/exif/1.0/aux/
xmlns:crs=“http://ns.adobe.com/camera-raw-settings/1.0/
xmlns:digiKam=“http://www.digikam.org/ns/1.0/
xmlns:exif=“http://ns.adobe.com/exif/1.0/
xmlns:photoshop=“http://ns.adobe.com/photoshop/1.0/
xmlns:pmi=“http://prismstandard.org/namespaces/pmi/2.2/
xmlns:tiff=“http://ns.adobe.com/tiff/1.0/
xmlns:xmp=“http://ns.adobe.com/xap/1.0/
xmlns:xmpDM=“http://ns.adobe.com/xmp/1.0/DynamicMedia/
xmlns:xmpRights=“http://ns.adobe.com/xap/1.0/rights/
xmlns:xmpMM=“http://ns.adobe.com/xap/1.0/mm/
xmlns:darktable=“http://darktable.sf.net/
xmlns:dc=“DCMI: DCMI Metadata Terms
xmlns:lr=“http://ns.adobe.com/lightroom/1.0/

The thumbnail script is actually pretty simple. It loops through the existing xmp file as a text file, and when it finds the ‘xmp:Rating=’ line it adds the ’ digiKam:Preview="’ line right after it with the base64 encoded content of the thumbnail. The script doesn’t actually parse the xmp file as an xml or xmp file. This means the ‘digiKam:Preview=’ line should always be right after ‘xmp:Rating=’ unless something else has read, parsed, and saved the xmp file. This also means the script can’t remove existing lines, like the Darktable edits.

Would you mind trying a few tests and sending me the xmp files? I’d like to track the evolutuion of the xmp file. Test 1 and 2 are the same, except for test 2, please DO NOT save the thumbnail in Darktable. You’ll need 2 new image files that don’t have an xmp sidecar for the test.

  1. Add the image to digiKam. Attach the xmp file to your reply.
  2. Launch Darktable. Attach the xmp file to your reply.
  3. Make edits in Darktable. Go to the lighttable view in Darktable. Wait 10 seconds. Attach the xmp file to your reply.
  4. Run the thumbnail script. Attach the xmp file to your reply.
  5. Exit Darktable. Attach the xmp file to your reply.

Test 2 is the same, but don’t run the thumbnail script.

I really appreciate your help!

Cheers,
Mike

Hi,

Good news! I have my first edited darktable thumbnail visible in the digikam thumbnail after the test 1. The edited version showed up without a rereading the xmp files on the side of digikam.

Here are the xmp’s of the test #1:
DSCN9367_#1.NRW.xmp (2.2 KB)
DSCN9367_#2.NRW.xmp (20.0 KB)
DSCN9367_#3.NRW.xmp (21.4 KB)
DSCN9367_#4.NRW.xmp (62.6 KB)
DSCN9367_#4.NRW.xmp (62.6 KB)

The test #2 xmp’s come in the next message.

Here are the test #2 xmp’s:

DSCN9368_#1.NRW.xmp (2.2 KB)
DSCN9368_#2.NRW.xmp (20.0 KB)
DSCN9368_#3.NRW.xmp (23.9 KB)
DSCN9368_#3.NRW.xmp (23.9 KB)

Hi @kaizubg,
I travelling yesterday. I’ll look at these today. Just by the sizes of the files from each step I can tell more metadata is being added.

Have you tried any more images to see if you get the thumbnail in digiKam?

Cheers,
Mike

Hi @Michmill ,

Have done some. The findings not promising and inconsistent. I’ll look again into this in the evening.

Cheers, Kai

Hi Kai,
I reviewed all the XMP files. Thank you for sending them!

At the moment I can’t fingure out why the Lua script would remove dt edits, or the thumbnail not show up in digiKam if the input xmp is properly formatted.

I did see in a few samples where the digiKam xmp namespace wasn’t included so this would explain why the thumbnail doesn’t show up, but I don’t understand why digiKam isn’t adding the namespace to xmp when dk imports the image. Maybe dk needs to do some type of operation that updates the xmp. I’ll look into it. Maybe I’ll add a function in dk that writes the xmp when the user selects Open or Open With… from the menu.

Thank you again for your help. If you could post a few more xmp files that don’t work, it would be helpful and appreciated.

Cheers,
Mike

Hi Michael,

I have it figured out. And there is a good explanation to it.

Your script is not srtipping anything from the XML, the correct lines just were never included into the XML. I found it after I started to use the following steps:

  1. Select the file or files in the digiKam thumbnail view that you want to process
  2. Write Metadata to [XMP] File/Files from the Item or Album submenu.
  3. Start darktable from the thumbnail menu item ‘Open with’ > darktable. Edit the file/s as you prefer; write the thumbnail using the script as instructed.
  4. After a short while digiKam automatically reads the new thumbnails into the thumbnail view. There is no need for a rereading of the XMP files.

These steps result as a correct XMP with the thumbnail and with the tags included and displayed in the thumbnail view.

(See attached DSCN0032.NRW.xmp)

If you don’t write the XMP file in digiKam, darktable generates it in a content that is not correct for digiKam. Nothing will be visible on the digikam side (thumbnail nor the tags). This happens also if you start darktable outside of digiKam.

(See attached DSCN0033.NRW.xmp)

Anyway, dt_dk_thumbnail works under a set of constraints that the user has be aware.

Thanks, Kai

The attached XMP’s
DSCN0032.NRW.xmp (69.1 KB)
DSCN0033.NRW.xmp (71.1 KB)

Hi @kaizubg,
That’s awesome. Thank you for tracking that down. I’ll update the documentation to make sure the user creates the xmp in digiKam before using the script.

Thank you so much!

Cheers,
Mike

1 Like