function get_dominant_color($image)
{
    $i = imagecreatefromjpeg($image); // eg: "image.jpg"

    for ($x = 0; $x < imagesx($i); $x++)
    {
        for ($y = 0; $y < imagesy($i); $y++)
        {
            $rgb = imagecolorat($i, $x, $y);
            $r = ($rgb >> 16) & 0xFF;
            $g = ($rgb >> 8) & 0xFF;
            $b = $rgb & 0xFF;
            $rTotal += $r;
            $gTotal += $g;
            $bTotal += $b;
            $total++;
        }
    }

    $rAverage = round($rTotal / $total);
    $gAverage = round($gTotal / $total);
    $bAverage = round($bTotal / $total);
}



/*************
* COOL TIP:
*
* To boost up the colors in a photo, get its dominant color,
* then, with a tool like PhotoShop or the GIMP, create a new
* layer filled with that color, then invert it and set the
* blend mode to "Overlay".
*************/