Default color profile of a JPEG file if not sRGB?

255 Views Asked by At

I think I am missing the whole point with color profile. I assumed that sRGB was the implicit one for JPEG. But it does not seems to be the case or at least I am doing something wrong with my commands.

Let's take a random image from the web, and use jpgicc to make sure there is no profile:

$ wget https://cloud.githubusercontent.com/assets/1139185/23364727/3da8c474-fcce-11e6-9f39-7e074e78aa33.jpg
$ jpgicc 3da8c474-fcce-11e6-9f39-7e074e78aa33.jpg demo1.jpg

Now let's embed the sRGB.icm profile back in:

$ wget https://raw.githubusercontent.com/mikesplain/imagemagick/master/config/sRGB.icm
$ md5sum sRGB.icm
1d3fda2edb4a89ab60a23c5f7c7d81dd  sRGB.icm
$ jpegtran -outfile demo2.jpg -icc sRGB.icm demo1.jpg

And finally apply sRGB.icm:

$ jpgicc demo2.jpg demo3.jpg

So in theory there should be no differences in between demo1.jpg and demo3.jpg, however:

$ compare -metric AE demo1.jpg demo3.jpg null:
106432

So what is the default color profile of a JPEG file if not sRGB.icm (1d3fda2edb4a89ab60a23c5f7c7d81dd) ?

2

There are 2 best solutions below

0
malat On BEST ANSWER

This was an issue with the internal JPEG representation. When I do:

$ jpgicc demo2.jpg demo3.jpg

I decompress a JPEG into an RGB buffer and then convert it back JPEG. So in my case I should have done an extra step:

$ jpgicc demo1.jpg demo4.jpg

Then:

$ compare -metric AE demo3.jpg demo4.jpg null:
0
0
Strom On

The original JPEG standard (ISO/IEC 10918-1:1994) doesn't define a default color space and instead explicitly states:

This Specification does not specify a complete coded image representation. Such representations may include certain parameters, such as aspect ratio, component sample registration, and colour space designation, which are application-dependent.

The JPEG standard Part 5 (ISO/IEC 10918-5:2013) defines JPEG File Interchange Format (JFIF), and has a section that defines the default color space as full range Rec. 601.

Also of note regarding sRGB, Amendment 1 to IEC 61966-2-1:1999 defines the YCbCr representation of sRGB (i.e. sYCC) using Rec. 601 constants, which can be surprising given that Rec. 709 is used for sRGB in RGB form.

The Android source code has an interesting comment, which also recommends Rec. 601 for JPEG:

 /*
 * Chromacity coordinates are unknown or are determined by the application.
 * Implementations shall use the following suggested standards:
 *
 * All YCbCr formats: BT709 if size is 720p or larger (since most video
 *                    content is letterboxed this corresponds to width is
 *                    1280 or greater, or height is 720 or greater).
 *                    BT601_625 if size is smaller than 720p or is JPEG.
 * All RGB formats:   BT709.
 *
 * For all other formats standard is undefined, and implementations should use
 * an appropriate standard for the data represented.
 */

So I would say that Rec. 601 has quite high credibility for being the default. Even when you consider sRGB as the default, the sRGB amendment regarding YCbCr brings you right back to at least using the Rec. 601 matrix for converting to RGB.

However because the original JPEG standard explicitly left it to the decision of application developers there are lots of different choices in the wild. Not every application follows the newer amended recommendations.