[csswg-drafts] [css-color4] Precision issues when converting colors between Lab and sRGB (#5262)

snigo has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color4] Precision issues when converting colors between Lab and sRGB ==
I'm working on my own Lab color library implementing conversions according to CSS color4 spec and keep noticing small inconsistencies when converting from Lab color space to sRGB, resulting in following:
```js
// pseudo
color('#f00').toLab().toRgb(); // #fe0000
```

I've checked whole sRGB color wheel (at saturation 1 and lightness 0.5) and xyz values on conversion back from Lab are **steadily** lower in the range [0.0005 - 0.004] that is enough for side effects.

Conversions `sRGB -> XYZ -> sRGB`, `Lab -> XYZ -> Lab` and `sRGB -> XYZ(D65) -> XYZ(D50) -> XYZ(D65) -> sRGB` are precise as expected which means that either conversion between sRGB and XYZ or between Lab and XYZ are off a bit.

I wonder if anyone else experienced the same result?


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5262 using your GitHub account

Received on Thursday, 25 June 2020 11:48:21 UTC