I came across a useful class on phpclasses.org. It extracts colors from an image file. I enhanced it a little and created an online test area where you can try it out. You can see it and download it here.
Credit must be given to Csongor Zalatnai of Hungary for creating the original class.
I hope you found this website useful.