Calculating dominate color of a picture?

I am wondering if it’s possible to calculate the dominate hex color of a jpg/png/tiff with flash? Has anyone done this?

Thanks
Paul