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

Feature request: access to raw icc profile #304

Open
HappySeaFox opened this issue Oct 6, 2021 · 3 comments
Open

Feature request: access to raw icc profile #304

HappySeaFox opened this issue Oct 6, 2021 · 3 comments

Comments

@HappySeaFox
Copy link

Hi! 😀

It would be great if jasper gives access to the raw ICC profile if the loaded image has it. Like libjpeg or libpng does. Raw profile = binary data and its length. Like that:

void *icc;
size_t icclen;

jas_image_iccp(image, &icc, &icclen);

It's also discussible if this function should allocate icc, or just return an already existing internal pointer.

@pjanx
Copy link

pjanx commented Dec 14, 2021

According to ISO/IEC 15444-1:2000, I.5.3.3, an ICC profile is in a Colour Specification box, named ‘colr’, starting at zero-based offset 3, iff the first octet, the METH field, is equal to 0x02 (Restricted ICC profile). There may be multiple such boxes. They are located within the JP2 Header superbox, named ‘jp2h’.

Jasper already contains JP2_BOX_COLR/JP2_COLR_ICC handling. The ‘colr’ box is saved within jp2_dec_t::colr->colr. Jasper, in fact, appears to have its own colour management handling.

jas_image_cmprof() retrieves an image's colour management profile, which has an iccprof field. jas_iccprof_createfromcmprof() creates a copy of it, and jas_iccprof_save() will serialize it in the normal format. This has the property that you might be able to receive a made-up but appropriate profile, even if there is no actual profile in the file.

I've typed this out as I was trying to figure out the current situation. I haven't tried doing CM with Jasper yet.

@mdadams
Copy link
Collaborator

mdadams commented Dec 14, 2021

I think that you can create a memory stream (i.e., buffer in memory) with jas_stream_memopen and then use jas_iccprof_save to write the ICC profile to the stream. You then have a copy of the ICC profile in your memory buffer. Would this not work?

@pjanx
Copy link

pjanx commented Dec 14, 2021

I would expect problems with v4 profiles. Jasper would probably profit from being able to use a different CMM, such as Little-CMS, Chrome's Skia (SkCMS), or Firefox's qcms (this one doesn't support all v4 profiles).

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

No branches or pull requests

3 participants