I have a problem using the jpeg_read_icc_profile() functionality.
I have a JPEG that I categorically know contains a valid ICC profile (I 
wrote it there myself using libjpeg-turbo, and both GIMP and djpeg -icc can 
extract it with no issue, and I can also see the details using exiftool). 
However when I write a function that tries to extract it as part of a jpeg 
reading routine, the call fails.
Here's the relevant part of my code:
```
int readjpg(const char* name, fits *fit){
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;

FILE *f = g_fopen(name, "rb");
if (f == NULL) {
siril_log_color_message(_("Sorry but Siril cannot open the file: %s.\n"), 
"red", name);
return OPEN_IMAGE_ERROR;
}
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, f);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);

// Check for an ICC profile
JOCTET *EmbedBuffer = NULL;
unsigned int EmbedLen;
#if LIBJPEG_TURBO_VERSION_NUMBER >= 2000000
if (jpeg_read_icc_profile(&cinfo, &EmbedBuffer, &EmbedLen)) {
printf("Read ICC profile from JPEG\n");
}
#endif
(... the code goes on to read the scanlines ...)
```
But jpeg_read_icc_profile() returns FALSE.  The image data itself decodes 
and displays fine, but I'm beating my head against a brick wall trying to 
understand why the ICC decoding doesn't work.

In case it matters the code I'm using to write the ICC profile is:
```
jpeg_write_icc_profile(&cinfo, (const JOCTET*) EmbedBuffer, EmbedLen);
```
(I'm recasting a cmsUInt8Number* buffer to JOCTET*)

But I think this is fine: as I said, other programs including 
libjpeg-turbo's own utilities can decode the profile fine.

Any help gratefully received,

Adrian.

-- 
You received this message because you are subscribed to the Google Groups 
"libjpeg-turbo User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to libjpeg-turbo-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/libjpeg-turbo-users/d2b81d0b-59bb-4165-a052-16175388d539n%40googlegroups.com.
  • [libjpeg-turbo-users] ICC ... Adrian Knagg-Baugh

Reply via email to