I'm looking for a Algorithm/Way to convert given HEX (e.g. #111111 R:0x11, G:0x11, B:0x11) to the closest X11 color number (Terminal is either 88 or 256 colors) using either Python, PHP, or VIM script and I was wondering if someone here knows a way or point me to a direction to do this.
Thanks in Advance.