Get dominant color

Anyone know of any tuts around that can get the dominant color of an imported jpg dynamically loaded? I am trying to match the background color to a imported jpg. Im not sure AS can do this but maybe some kind of server side script?