There are several XMP tags that DigiKam writes for ratings, but the most important one will be:
xmp:Rating="0" // values 0 (none) to 5
digiKam:ColorLabel="0" // values 0 (none) to 9.
// xmp:Label is used only if it is a Lightroom-compatible color
RawTherapee uses:
[General]
Rank=0 // values 0 (none) to 5
ColorLabel=0 // RawTherapee uses only 5 colors (0-5)
If you feel brave enough, you can use regex to transfer the information from PP3 to XMP or vice versa.
Steps:
- Download images from camera (d'uh).
- Open them on Digikam. Delete bad shots, rate the rest of the shots (make sure that XMPs are written).
- Open RawTherapee and open the files' folder. This should write the
.pp3
files for all images. Close RT / go to a different folder.
- Regex it - We will dive into that in a moment!
- Open the folder again with RT. Enjoy how easily text files are manipulated.
I created a Python (version 3) script that does the regex-operation for all PP3s and XMPs in a folder.
NB: This code might damage your sidecar files. It might not work with other versions than DigiKam's 6.3.0 and RawTherapee's 5.7. Make a backup first, then try this!
Walkthrough for above-mentioned 4.:
- Make sure DigiKam has set a color tag: if you do not have any set, apply one, save metadata, delete the color, save metadata again.
- Install Python,
- Open a console,
cd
to the folder with the images,
python <path to your python script>
, where your script is:
import re
from pathlib import Path
# Find only *.pp3 and *.xmp in this folder, keep only those that have a twin with the other extension:
found_pp3 = [str(x.resolve()) for x in Path("./").glob('*.pp3') if
Path(re.sub('\.pp3$', '.xmp', str(x.resolve()), flags=re.MULTILINE)).is_file()]
found_xmp = [str(x.resolve()) for x in Path("./").glob('*.xmp') if
Path(re.sub('\.xmp$', '.pp3', str(x.resolve()), flags=re.MULTILINE)).is_file()]
print(str(len(found_pp3)) + " | " + str(len(found_xmp)) + " files found.")
# Making sure that A.pp3 is used as the same time as A.xmp:
found_pp3 = sorted(found_pp3, key=str.lower)
found_xmp = sorted(found_xmp, key=str.lower)
# Having fun with regex:
i = 0
while i < len(found_pp3):
print(found_xmp[i] + " --> " + found_pp3[i])
# Copying content of 1st/2nd/... file into variable:
temp_xmp = Path(found_xmp[i]).read_text(encoding='utf-8')
temp_pp3 = Path(found_pp3[i]).read_text(encoding='utf-8')
# Substituting Stars (aka rank/rating) from xmp to pp3:
temp_xmp_rating = re.search('xmp:Rating=\"(.+?)\"', temp_xmp).group(1)
temp_pp3 = re.sub('Rank=\d', 'Rank=' + temp_xmp_rating, temp_pp3)
# Substituting color-tags from xmp to pp3:
temp_xmp_color = re.search('digiKam:ColorLabel=\"(.+?)\"', temp_xmp).group(1)
# DigiKam has 0-9 tags, RawTherapee 0-5.
# Translate orange to yellow and grey/white/black to none:
if(int(temp_xmp_color) == 3):
temp_xmp_color = "4"
elif(3 < int(temp_xmp_color) <= 6):
temp_xmp_color = str(int(temp_xmp_color) - 1)
elif(int(temp_xmp_color) > 6):
temp_xmp_color = "0"
temp_pp3 = re.sub('ColorLabel=\d', 'ColorLabel=' + temp_xmp_color, temp_pp3)
# Overwriting the pp3:
Path(found_pp3[i]).write_text(temp_pp3, encoding='utf-8')
i += 1
print("Done!")
I made a repository for this code which now can also work in the opposite direction. It works well for me so far, but again:
NB: This code might damage your sidecar files. It might not work with other versions than DigiKam's 6.3.0 and RawTherapee's 5.7. Make a backup first, then try this!
It should do well, though, especially as long as RawTherapee keeps using Rank=
and ColorLabel=
without ambiguity (if they rename them, the script will not change anything) and DigiKam does the same with xmp:Rating=
and digiKam:ColorLabel=
.