wow, al principio no entendi muy bien tu pregunta, pero despues la lei bien y me parecio realmente interesante, tanto que investigue un poco y encontre una respuesta,
bueno tu debes saber que el codigo hex de color es realmente rgb, bueno si conviertes ese color a HSL, (hue saturation and luminosity) entonces es mucho mas sencillo saber que tan claro el color es. encontre una funcion en internet que te permite hacer eso usando php:
Código:
/ Sisään: v1, v2, v3 [0..255]
// Ulos: {0,1,2} [0..1]
function rgb_to_hsl($v1, $v2, $v3){
$v[0] = $v1/255; // red
$v[1] = $v2/255; // green
$v[2] = $v3/255; // blue
$max = max($v);
$min = min($v);
$L = ($max+$min)/2;
if($max == $min){
$H = 0;
$S = 0;
}
if($L <= 0.5)
$S = ($max-$min)/($max+$min);
else
$S = ($max-$min)/(2-$max-$min);
$delta = $max-$min;
if($v[0] == $max) $H = ($v[1]-$v[2])/$delta;
if($v[1] == $max) $H = 2+($v[2]-$v[0])/$delta;
if($v[2] == $max) $H = 4+($v[0]-$v[1])/$delta;
$H *= 60;
if($H < 0) $H += 360;
$out[0] = $H/360;
$out[1] = $S;
$out[2] = $L;
return $out;
}
la puedes modificar un poco y acoplarla a tus necesidades, no he probado si funciona pero si no ya te di el metodo :) recuerda que lo que te interesa a ti es $L (luminosity)