colorsrgbsrgb

Are RGB images converted to sRGB automatically before being viewed in web browser?


If we have an RGB image, most browsers and, in fact, monitors only support sRGB space. I am trying to understand something important. Does the monitor/web then convert each of the pixels in the image to sRGB and then display it? Meaning we are actually seeing the sRGB version of the image.

Also, if that is the case, which formula can we use to do the conversion, and if we did the conversion ourself, I assume we would get an image that 'looks' exactly the same as the original?


Solution

  • The pixel values in an image file are just numbers. If the image is "in" a space larger than sRGB (such as ProPhoto), the pixel values will only be "converted" to sRGB if you have color management enabled, OR you perform the conversion yourself.

    A browser or device will only convert tagged images of a non-sRGB colorspace TO sRGB IF there is a color management engine.

    With no color management, and a standard sRGB monitor, all images will displays "as if" they were sRGB, regardless of their colorspace. I.e. they may display incorrectly.

    Even with color management, if the image is untagged, it will be displayed as whatever default (usually sRGB) the system is set to use.

    As for formulas: the conversion is known generally as "gamut mapping" — you are literally mapping the chromaticity components from one space to another. There are multiple techniques and methods which I will discuss below with links.

    If you want to do you own colorspace conversions, take a look at Bruce Lindbloom's site. If you want a color management engine you can play around with, check out Argyll, and here is a list of open source tools.


    EDIT TO ADD: Terms & Techniques

    Because there are other answers here with some "alternate" (spurious) information, I'm editing my answer here to add and help clarify.

    Corrections

    1. sRGB uses the same primary and whitepoint chromaticities as Rec.709 (aka HDTV). The tone response curve is slightly different.
    2. sRGB was developed by HP and Microsoft in 1996, and was set as an international standard by IEC circa 1998.
    3. W3.org (World Wide Web Consortium.) set sRGB as the standard for all web content, defined in CSS Color.
      • Side note, "HTML" is not a standards organization, it is a markup language. sRGB was added to the CSS 3 standard.
    4. Profiles do nothing if there is no color management system in place.

    And to be clear (in reference to another answer): RGB is a color MODEL, sRGB is a color SPACE, and a parsable description like an ICC profile of sRGB is a color PROFILE.

    Second, sRGB is the STANDARD for web content, and RGB values with no profile displayed in a web browser are nominally assumed to be sRGB, and thus interpreted as sRGB in most browsers. HOWEVER, if the user has wide gamut (non-sRGB monitors) and no color management, then a non-color managed browser is typically displaying at the display's colorspace which can have unexpected results.

    Terms

    Techniques

    Colorspace transforms and conversions are non-trivial. It's not as if you can just stick image data through a nominal formula and have a good result.

    A reading through the several links above will help, and I'd also like to suggest Elle Stone's site. particularly regarding profiles.