Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-color-4] Slightly incorrect sRGB inverse transfer function #9467

Closed
jessestricker opened this issue Oct 13, 2023 · 3 comments
Closed

[css-color-4] Slightly incorrect sRGB inverse transfer function #9467

jessestricker opened this issue Oct 13, 2023 · 3 comments

Comments

@jessestricker
Copy link

jessestricker commented Oct 13, 2023

The sRGB inverse transfer function, the one from the non-linear to the linear sRGB values, is given in the CSS spec with a comparison that diverges from the sRGB standard.

The CSS spec states:

if (abs < 0.04045) {
  cl = c / 12.92;
}
// ...

But in the DIN EN 61966-2-1:2003-09, which is the German version of the EN 61966-2-1:2000 + A1:2003 (“sRGB standard”),
the comparison is stated using the less-than-or-equal operator, so the sample code should be:

if (abs <= 0.04045) { // note the use of the less-than-or-equal operator
  cl = c / 12.92;
}
// ...

Is this deviation from the sRGB standard intentional? Is it negligible? Or is the German version of the sRGB standard incorrect?

The affected sections are:

@jessestricker
Copy link
Author

Note: The comparison with the value 0.0031308 in the actual transfer function (from the linear to the non-linear sRGB values, as seen in function gam_sRGB(RGB) in section 17) is correct and matches the DIN EN 61966-2-1:2003-09.

@facelessuser
Copy link

It should be noted that the CSS example in Section 17 references a Wikipedia article that also uses <= as well: https://en.wikipedia.org/wiki/SRGB.

@svgeesus
Copy link
Contributor

svgeesus commented Nov 1, 2023

Fixed.

Note that this will only change the result if a component value is exactly 0.04045 × 255 = 10.31475

@svgeesus svgeesus closed this as completed Nov 1, 2023
svgeesus added a commit to color-js/color.js that referenced this issue Nov 1, 2023
danburzo added a commit to Evercoder/culori that referenced this issue Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants