Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if display supports HDR (High Dynamic Range) color in JavaScript?

Is it possible in JavaScript to detect if the browser's monitor supports HDR?

I have the requirement to display a HDR certificate on a webpage when the visitor is using a HDR monitor, but I've expressed to the client that this might not be possible. We've been able to embed video that supports HDR and it plays back correctly on Chrome for Windows.

So far in my research I've found no way of detecting such a capability.

The closest thing I've found is the Screen.colorDepth API

like image 243
Reactgular Avatar asked Aug 07 '19 18:08

Reactgular


1 Answers

Made a few experiments from the code suggested by @Andreas and tweaked it a tiny bit.

if (screen.colorDepth > 24 && window.matchMedia('(color-gamut: p3)').matches) { 
  /* use HDR content */ 
} else { 
  /* use SDR content */ 
}
like image 56
richbray89 Avatar answered Nov 15 '22 09:11

richbray89