Re: [csswg-drafts] [css-color-4] matching displayed colors between CSS colors and images when those colors are outside the displayable gamut (#10055)

> > In the current CSS gamut mapping specification, it is impossible for a content author to achieve the same color across CSS, images, video, and canvas.
> 
> It is absolutely possible to color match even when following the specification. But only for colors that fit within the displayable color gamut.
> 
> Shipping the css-color-4 gamut mapping algorithm does not take away a feature from authors.
> 
> Authors can also use `@media (color-gamut: ...)` to conditionally apply other colors, images, ... So even wider gamut images and css colors can be color matched without causing issues for users on narrower gamut screens.

> Is `@media (color-gamut: ...)` sufficient for those authors that do need to match colors?

No, it is still impossible to ever ensure color matching if CSS gamut mapping is enabled, even with the `color-gamut` query. The important distinction is that:

* The `color-gamut` query gives an approximation of the display's gamut.
* The CSS gamut mapping maps to the display's true gamut.

These two gamuts are not necessarily the same. There are three cases to consider:

* The display's true gamut exactly matches the `color-gamut` query
  * In this case you are correct, it is possible to ensure color matching by staying within the `color-gamut` gamut.
  * An exact match happens like this almost never.
* The display's true gamut is larger than the one reported by the `color-gamut` query
  * If the author stays within the gamut reported by `color-gamut` then color matching is preserved.
  * But there exist colors that the display is capable of producing but are not in the gamut reported by `color-gamut`.
  * The author cannot use these colors, because there is no way to know if they will match.
* The display's true gamut is smaller than the one reported by `color-gamut`
  * In this case, there are colors that are within `color-gamut` but outside of the display's gamut.
  * Color matching will not be preserved for these colors.

> If this is not sufficient, what is missing?

One needs to know the exact gamut that CSS colors are being mapped to. That is a very potent fingerprinting vector. It's also very hard to provide accurately (e.g, print, E-ink displays, and non-3-primary displays don't even have the usual gamut shape).

One could try to update the spec to make CSS map to the gamut reported by `color-gamut`, but that also breaks down.

> > Also of note is the prominence of color matching with images as the motivation in [this post](https://webkit.org/blog/6682/improving-color-on-the-web/).
> 
> Even this post mentions the various ways to use `(color-gamut: p3)` as a critical part to color matching :) This is why the features exists.

The post says the exact opposite. It says: "If you serve wide-gamut images to users not on a wide-gamut display, WebKit will color-match the images and show them in the sRGB space."

And then continues: "However, this conversion into sRGB can be done a few ways and isn’t guaranteed to happen identically on other browsers or platforms. As a discerning Web developer or designer you will want to convert your images offline to better control what the end user will see. Also, embedding the color profile adds a little to the file size, so you might not want to send that extra data if it isn’t necessary."

_That_ is why the `color-gamut` feature exists.

-- 
GitHub Notification of comment by ccameron-chromium
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10055#issuecomment-2014683875 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 22 March 2024 09:25:05 UTC