Convert RGB, Hex or any other color format to "Standard Color" Programmatically Forgive me in advance for my ignorance.

Using the PHP function imagecolorat, I have a solution that presently delivers a set of the most dominant hex color codes available inside of an image.

Is there a known library that will allow me to then take the hex color code, RGB code (or any other standard color code) and simplify them down, or rather "match" them to a limited set of "common colors", such as red, brown, green, yellow, grey, blue, etc?

For example, #944D70, which is a shade of purple, would be matched to the color 'purple'.

Alternatively:

Is there a particular pattern or range to RGB colors that would allow me to write such a library myself?

For example, 0,0,0 thru 20,20,20 might all be considered a "black" color. However, it seems as if organizing such a library would be very exhausting if done manually.
Problem is that people do not really agree on a 1:1 mapping of color names. But yes such tools exists, this is a simple nearest neighborhood test. You could use any spatial query module to do this. Here is a simple (naive) python example: 

from __future__ import print_function
import webcolors
from scipy.spatial import KDTree

# lets populate some names into spatial name database
hexnames = webcolors.css3_hex_to_names
names = []
positions = []

for hex, name in hexnames.iteritems():
    names.append(name)
    positions.append(webcolors.hex_to_rgb(hex))

spacedb = KDTree(positions)

# query nearest point
querycolor = (10,88, 200)
dist, index = spacedb.query(querycolor)

print('The color %r is closest to %s.'%(querycolor, names[index]))


Which results in: The color (10, 88, 200) is closest to royalblue.

I'm using here the 140 css3 defined colors. Bigger and more comprehensive lists can be found online, if you want a smallerlist that would also work. Theres all kinds of possible things you could do, you could for example linearize the sRGB space before calculating distances to name. You could ask for 3 closest names and give double names if the names are halfway.