Since you haven't specified any particular language/script to detect the darker/lighter hex, I would like to contribute a PHP solution to this
Demo
$color_one = "FAE7E6"; //State the hex without #
$color_two = "EE7AB7";
function conversion($hex) {
$r = hexdec(substr($hex,0,2)); //Converting to rgb
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
return $r + $g + $b; //Adding up the rgb values
}
echo (conversion($color_one) > conversion($color_two)) ? 'Color 1 Is Lighter' : 'Color 1 Is Darker';
//Comparing the two converted rgb, the greater one is darker
As pointed out by @Some Guy, I have modified my function for yielding a better/accurate result... (Added Luminance)
function conversion($hex) {
$r = 0.2126*hexdec(substr($hex,0,2)); //Converting to rgb and multiplying luminance
$g = 0.7152*hexdec(substr($hex,2,2));
$b = 0.0722*hexdec(substr($hex,4,2));
return $r + $g + $b;
}
Demo 2