imagemagickjpegcolor-profile

Default color profile of a JPEG file if not sRGB?


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) ?


Solution

  • 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