This Python script reads a text file and looks for 12 basic colors: blue, black, white, red, green, yellow, purple, pink, orange, brown, gray, and gold. First it counts the total number of times such words are used; then it visualizes the percentage of each in a pie chart, in effect creating a simple color swatch of a given text. For example, this is the color palette for Edgar Allan Poe's 'Masque of the Red Death' (1842).

Upload a txt file here to try it out for yourself. Another web page will open up that gives you your palette as a png. If you don't have a text file handy, the following are great places to get one: Project Gutenberg, Bartleby, Archive.org

'MASQUE OF THE RED DEATH' (1842)

For more information, click here.