Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No function to retrieve cmsProfileID #38

Closed
haasn opened this issue Jan 4, 2015 · 3 comments
Closed

No function to retrieve cmsProfileID #38

haasn opened this issue Jan 4, 2015 · 3 comments

Comments

@haasn
Copy link

haasn commented Jan 4, 2015

I see a definition for cmsProfileID in lcms2.h, and it's referenced inside cmsICCHeader, but I cannot find any way to retrieve this information through the actual LittleCMS 2 API.

Is it possible to get the profile ID somehow? If not, could it be added?

My use case: I want to quickly figure out if an ICC profile has changed, as that invalidates my cache. Currently I am comparing the entire file against a reference copy, but that doesn't play nicely with profiles loaded from memory (or generated from scratch), and it's also less efficient to store a full copy of a potentially large ICC profile rather than just a 128-bit hash.

@mm2
Copy link
Owner

mm2 commented Jan 4, 2015

Hi, the functions to get/set/compute profileID are available since lcms2-2.0
cmsGetHeaderProfileID()
cmsSetHeaderProfileID()
cmsMD5computeID()

There is documentation in the API reference manual
Regards
Marti

@mm2 mm2 closed this as completed Jan 4, 2015
@haasn
Copy link
Author

haasn commented Jan 4, 2015

Thanks, I didn't find the section for them since it was so far at the bottom.

On a related note, do you know why identically generated profiles end up with different profile IDs? eg. see this file

#include <stdio.h>
#include <lcms2.h>

int main() {
    cmsCIExyY d65 = {0.3127, 0.3290, 1.0};
    cmsCIExyYTRIPLE prim_rec709 = {
        .Red   = {0.64, 0.33, 1.0},
        .Green = {0.30, 0.60, 1.0},
        .Blue  = {0.15, 0.06, 1.0},
    };
    cmsToneCurve *tc = cmsBuildGamma(NULL, 2.2);

    cmsHPROFILE p = cmsCreateRGBProfile( &d65, &prim_rec709, (cmsToneCurve*[3]) { tc, tc, tc });
    cmsSetProfileVersion(p, 2.0);
    cmsMD5computeID(p);

    cmsProfileID id;
    cmsGetHeaderProfileID(p, id.ID8);
    printf("id: 0x%x%x%x%x\n", id.ID32[0], id.ID32[1], id.ID32[2], id.ID32[3]);

    cmsCloseProfile(p);
    cmsFreeToneCurve(tc);

    return 0;
}

Building the program and running it a few times gives me results like this:

id: 0x655d952fffec2bbbb3ae6ed256b0d281
id: 0x5afd5f96bb3c3b6ef906c050c32a80
id: 0x5afd5f96bb3c3b6ef906c050c32a80
id: 0xcc05703d8c8af55cf7aa321640112c6b
id: 0xb2c8a0b3ef6d3c431b962e1383eb11e0
id: 0xb304d4397782884e92c6d7716e72693
id: 0x1e59381940a058dc36ed82c9384722fc
id: 0x1e59381940a058dc36ed82c9384722fc

Do you know what causes that?

@mm2
Copy link
Owner

mm2 commented Jan 4, 2015

On a related note, do you know why identically generated profiles
end up with different profile IDs? eg. see this file
Do you know what causes that?

ICC profiles holds a creation time stamp that contributes to the MD5
profile ID, strictly speaking each time you create a new profile it is
indeed different. This is not a lcms behavior but something imposed by
the ICC spec. The only way to obtain exact ID is by copying the file
or memory block that holds the profile.

Regards
Marti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants