Hi, all! Recently, I’ve been trying to take a deeper dive into how Darktable writes to XMP sidecar files, and I have a few questions.
Consider this excerpt from the history stack of one of my XMP files:
How exactly is params encoded? I know that XMP files follow RDF/XML syntax, which imposes some restrictions on how data is stored (base64, I think?), but I’ve also heard that Darktable compresses param hex strings with gzip before writing - I’m not fully sure as to how this all happens and why.
Are blendop_params written the same way, and if not, why?
I’ve started digging through the source code to answer my own questions, but I think it would be much easier if someone with more insight could walk me through exactly how these parameters are written to XMP files and the rationale behind this process.
Here is a python project i created a few years ago to understand this very thing. Essentially the params are represented as a packed struct. This project is somewhat outdated, but it should still be relevant to understanding how the fields are packed.
If we peek inside, say, hotpixels.py, you can see how the fields are arranged. The first 8 bytes are two floats and the remaining 8 bytes are to integers.
The fields orders are defined in structs like these: darktable/hotpixels.c at master · darktable-org/darktable · GitHub. Each iop in darktable has something similar.
For modules with lots of parameters, darktable will compress the struct.
has routines for compressing and decompressing the params.
I think these cover the blendops (or at least attempts to). Another packed struct.
after almost one year, I have the same problem…don’t really understand how to convert xmp params to human readable value.
If I want to decompress like descriped in your def “dt_exif_decompress”, I will get an error:
zlib.error: Error -3 while decompressing data: incorrect header check
Maybe you can show me how to convert " darktable:params=“00c01f400000803f0080cc3f0000c07f”" with you script?