src/Color.php
public function lumDiff($color1, $color2)
    {
        list($R1, $G1, $B1) = is_array($color1) ? $color1 : $this->rgb($color1);
        list($R2, $G2, $B2) = is_array($color2) ? $color2 : $this->rgb($color2);

        $L1 = 0.2126 * pow($R1 / 255, 2.2) +
            0.7152 * pow($G1 / 255, 2.2) +
            0.0722 * pow($B1 / 255, 2.2);

        $L2 = 0.2126 * pow($R2 / 255, 2.2) +
            0.7152 * pow($G2 / 255, 2.2) +
            0.0722 * pow($B2 / 255, 2.2);

        if ($L1 > $L2) {
            return ($L1 + 0.05) / ($L2 + 0.05);
        } else {
            return ($L2 + 0.05) / ($L1 + 0.05);
        }
    }
public function lumDiff($color1, $color2)
    {
        list($R1, $G1, $B1) = is_array($color1) ? $color1 : $this->rgb($color1);
        list($R2, $G2, $B2) = is_array($color2) ? $color2 : $this->rgb($color2);

        $L1 = 0.2126 * pow($R1 / 255, 2.2) +
            0.7152 * pow($G1 / 255, 2.2) +
            0.0722 * pow($B1 / 255, 2.2);

        $L2 = 0.2126 * pow($R2 / 255, 2.2) +
            0.7152 * pow($G2 / 255, 2.2) +
            0.0722 * pow($B2 / 255, 2.2);

        if ($L1 > $L2) {
            return ($L1 + 0.05) / ($L2 + 0.05);
        } else {
            return ($L2 + 0.05) / ($L1 + 0.05);
        }
    }
public function lumDiff ( $ color1 , $ color2 ) { list ( $ R1 , $ G1 , $ B1 ) = is_array ( $ color1 ) ? $ color1 : $ this -> rgb ( $ color1 ) ; list ( $ R2 , $ G2 , $ B2 ) = is_array ( $ color2 ) ? $ color2 : $ this -> rgb ( $ color2 ) ; $ L1 = 0.2126 * pow ( $ R1 / 255 , 2.2 ) + 0.7152 * pow ( $ G1 / 255 , 2.2 ) + 0.0722 * pow ( $ B1 / 255 , 2.2 ) ; $ L2 = 0.2126 * pow ( $ R2 / 255 , 2.2 ) + 0.7152 * pow ( $ G2 / 255 , 2.2 ) + 0.0722 * pow ( $ B2 / 255 , 2.2 ) ; if ( $ L1 > $ L2 ) { return ( $ L1 + 0.05 ) / ( $ L2 + 0.05 ) ; } else { return ( $ L2 + 0.05 ) / ( $ L1 + 0.05 ) ; } }
Uses luminosity to calculate the difference between the given colors.
The returned value should be bigger than 5 for best readability.

@param string|array $color1
@param string|array $color2
@return double
Uses luminosity to calculate the difference between the given colors . The returned value should be bigger than 5 for best readability .