need to parse DCP camera profile created with dcamprof

Hi. I want to manually apply DCP profile created by dcamprof in my Python code. I’m reading Sony ARW with rawpy library which is a wrapper over libraw. But it is unable to apply DCP. And I failed to find any possibility, even ChatGPT failed lol. So I started to try reading my DCP file… and it appeared it is some kind of binary? Not sure I’m able to find exact place in dcamprof code to figure out how to extract all the data from that file. Any suggestions, hints, pointers? Thanks

Maybe you can leverage this…

I’m a little bit rusty on this, but I’m fairly certain exiftool can parse the fields within a DCP.

exiv2 failed last time I tried.

It has been a while though. exiv2 might play nice with bare DCP files now.

AFAIK this is still the state of things.

In essence, a .dcp file is using a minimal TIFF-like container to store DCP related tags just like inside a DNG.

Yup, that is what I remember, and at least 2-3 years ago, exvi2 didn’t grok that degree of “minimality” but exiftool did.

I can’t remember if tifffile handled DCPs properly, need to poke at that again. It may have?

Depends, it (and exiv2) just needs to be tolerant of the slightly different starting magic bytes to the standard TIFF ones. The details are in the “ExtraCameraProfiles” section of the DNG spec - basically those embedded extra profiles are the equivalent of the standalone .dcp

If it doesn’t, should be easy to patch and send a change upstream. :wink:

Fully “applying” a dcp is not trivial, Anders describes it here:

http://rawtherapee.com/mirror/dcamprof/camera-profiling.html#dng_profiles

First, to read the file you can just look at the profile.json generated by dcamprof make-profile. It’ll contain all the matrices and LUTs use to create the dcp. Now, if you want to pull them from the dcp file itself, you can run dcamprof dcp2json and it’ll puke out a JSON representation of the dcp contents, and then you can cherry-pick the matrices and luts.

2 Likes

FYI, here’s the work in progress change for exiv2 DCP parsing support.

2 Likes

Will give that a test later this week, thanks!

But as @ggbutcher points out, reading it is just the first step in a long journey of using its content in a meaningful fashion… But definitely useful for analysis and “copy this metadata into another file” purposes.