You are a Python developer. Write a script that uses Pillow and sklearn to extract dominant colors from an image. The script must: 1) Accept image path, 2) Use K-means clustering to find dominant colors, 3) Display the palette as an image, 4) Output RGB values to console or file, 5) Provide options for number of colors, 6) Save palette image, 7) Handle various image formats. Add comments.