Does anyone know if there is a script available to detect darkness/lightness in an image (HTML included) using a client sided script?
I basically want to be able to detect the brightness of image (dark/light) used in the background and have CSS/HTML/jQuery/JS adapt the page based on a variable that is either dark or light (true or false).
I know there are server-side scripts available but cannot use that for this particular development project.
This function will convert each color to gray scale and return average of all pixels, so final value will be between 0 (darkest) and 255 (brightest)
Usage:
JSFiddle:
http://jsfiddle.net/s7Wx2/