CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
saurabheights
Posts: 8
Joined: 2016-09-24T05:16:10-07:00
Authentication code: 1151

CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Post by saurabheights »

Hi,
This question comes as a follow up from no support of CMYK jpegs by cwebp.

Please check this: https://bugs.chromium.org/p/webp/issues ... ?id=311#c5

Since, CMYK is not supported by djpeg, how can imagemagick handle CMYK images. These images have color transform YCCK.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Post by snibgo »

I'm not sure if the question is about reading CMYK JPEG files, or converting CMYK pixels to RGB.

IM's coders/jpeg.c contains code for reading JPEG CMYK pixels, and storing those in IM's data structures. Then, if you want, you can convert those CMYK pixels to sRGB or any other colorspace, but that is independent of JPEG.
snibgo's IM pages: im.snibgo.com
saurabheights
Posts: 8
Joined: 2016-09-24T05:16:10-07:00
Authentication code: 1151

Re: CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Post by saurabheights »

Thank you.
The question was about if djpeg cannot decode jpegs with CMYK profile, then how was imagemagick able to do it. The need arise because I was assuming that IM uses delegates for decoding an image, thus all decoding must be done by libjpeg, libpng, etc depending on the file type.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Post by fmw42 »

I do not understand your question. JPEG supports CMYK and libjpeg will read or write it. IM uses libjpeg for JPEG files.

I do not know if djpeg or cwebp/dwebp handles CMYK. Webp format is not the same as JPEG and requires the webp delegate to read/write it. I do not know if webp supports CMYK.

IM supports CMYK and YCC, but I do not see YCCK listed as a supported colorspace.
saurabheights
Posts: 8
Joined: 2016-09-24T05:16:10-07:00
Authentication code: 1151

Re: CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Post by saurabheights »

@fmw2: You can ignore cwebp/dwebp. The root problem is I am unable to read CMYK jpeg images using djpeg.

As you said "JPEG supports CMYK and libjpeg will read or write it. IM uses libjpeg for JPEG files."

I tried using 'djpeg', from `sudo apt-get install libjpeg-progs`.
I tried both commands below and failed:-
$> djpeg CMYK.jpeg
PPM output must be grayscale or RGB
$> djpeg -rgb CMYK.jpeg
Unsupported color conversion request

$> mogrify CMYK.jpeg //This worked. Read and Wrote back the image.

P.S. :- regarding cwebp: cwebp converts jpegs to webp. But to do that cwebp uses libjpeg, but that's where it fails to decode the jpeg as reported from their end. Thus issue is decoder(libjpeg) and not cwebp.
Finally: I looked here : https://github.com/webmproject/libwebp/ ... /jpegdec.c
Clearly, cwebp is using the libjpeg library directly.

If you can provide any hint, that would be helpful.

I will next try to see if installing libjpeg9a(or if there is another latest release), resolves the issue and lets djpeg decode CMYK jpegs.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: CMYK - How does imagemagick reads it, when djpeg doesn't supports?

Post by fmw42 »

Correctly if I misunderstand. But djpeg is not part of Imagemagick, so this issue likely should be addressed to the djpeg developers. I do not know if you can install djpeg as a delegate to Imagemagick. I am not a developer, so they would have to comment.

Sorry I do not know the connection between djpeg and libjpeg. Best to upgrade each to the most current. libjpeg is at 9 (90). At least that is what I am using.
Post Reply