I created a function called "extract_colours()" in my "rPlotter" package. Using this function, any image in PNG, JPG, JPEG or TIFF format can be converted into a simple colour palette.
YET, this is my very first attempt, the colours are only sorted by alphabetical order at the moment. More work is needed to arrange colours based on colour theory and other factors.