mozjpeg icon indicating copy to clipboard operation
mozjpeg copied to clipboard

Wrong colorspace error

Open Ser-Gen opened this issue 8 years ago • 4 comments

I have problem with compressing an image.

broken

With settings -quality 92 I got this file.

cjpeg_broken

In iOS Safari, Photoshop and in some other tools this image looks a bit more glamourous

image

Most likely it happens because Adobe Tag of original image APP14 have a ColorTransform somehow set to 0 [Unknown (RGB or CMYK)].

Maybe show an error about wrong colorspace?

FYI Guetzli throw error before proceed image https://github.com/google/guetzli/blob/cb5e4a86f69628f685f2b78d7429e248ab83d8d7/guetzli/processor.cc#L905

Seems like they check it here https://github.com/google/guetzli/blob/0e4900983924d1936f3a0ddf9b37164543e8fb5b/guetzli/jpeg_data_decoder.cc#L25

> cjpeg -version
mozjpeg version 3.2 (build 20170918)

Ser-Gen avatar Sep 27 '17 09:09 Ser-Gen

Yes, indeed. This is probably a CMYK JPEG which isn't supported. If you can use PNG input for mozjpeg.

kornelski avatar Sep 27 '17 15:09 kornelski

Adobe Tag of original image APP14 have a ColorTransform somehow set to 0

Really? Source file is RGB (gbrp). It is not CMYK or YCCK or whatever. What does the standard say about the default? I do not understand why the output file (that is NOW YUV 4:4:4) is not marked as being NOT CMYK? I mean it is kinda obvious that you should not copy this particular parameter in this case.

Also GIMP opens the second picture correctly. Just a bug (in defaults) in Photoshop?

ValZapod avatar Jan 13 '21 11:01 ValZapod

So, indeed. Source is for sure RGB. As mediainfo prints:

00061 Component - R - 1 (0x1) - 1 (0x1) (3 bytes) 00061 Ci - Component identifier: 82 (0x52) 00062 Hi - Horizontal sampling factor: 1 (0x1) - (4 bits) 00062 Vi - Vertical sampling factor: 1 (0x1) - (4 bits) 00063 Tqi - Quantization table destination selector: 0 (0x00) 00064 Component - G - 1 (0x1) - 1 (0x1) (3 bytes) 00064 Ci - Component identifier: 71 (0x47) 00065 Hi - Horizontal sampling factor: 1 (0x1) - (4 bits) 00065 Vi - Vertical sampling factor: 1 (0x1) - (4 bits) 00066 Tqi - Quantization table destination selector: 0 (0x00) 00067 Component - B - 1 (0x1) - 1 (0x1) (3 bytes) 00067 Ci - Component identifier: 66 (0x42) 00068 Hi - Horizontal sampling factor: 1 (0x1) - (4 bits) 00068 Vi - Vertical sampling factor: 1 (0x1) - (4 bits) 00069 Tqi - Quantization table destination selector: 0 (0x00)

iOS Safari, Photoshop

That is a bug there. The file you got has 3 components! It means it must be RGB. It cannot be CMYK or YCCK, those are 4 components!

What does the standard say about the default?

ColorTransform somehow set to 0 [Unknown (RGB or CMYK)] is not really Unknown. It is RGB if 3 components and CMYK if 4. See: https://stackoverflow.com/questions/50798014/determining-color-space-for-jpeg/50861048

Also, CMYK can be KMYC, as in Samatra PDF... A bug. https://github.com/libjpeg-turbo/libjpeg-turbo/commit/12781cb5558bc1f6d66ed840ed15267d503ffffc

Also, I tried to change your second file to have R, G, B as Ci's (Component identifiers): as hex 0x52, 0x47, 0x42, but unfortunately there are some further checks down the binary.

ValZapod avatar Mar 23 '21 07:03 ValZapod

not really Unknown

Really unknown is not 0, it is number 4, as here in chromium: https://chromium-review.googlesource.com/c/chromium/src/+/1235214/13/third_party/WebKit/LayoutTests/images/resources/cs-uma-cmyk-unknown-transform.jpg

APP14 Flags 0                   : (none)
APP14 Flags 1                   : (none)
Color Transform                 : Unknown (4)

ValZapod avatar Mar 23 '21 12:03 ValZapod