So, i'm creating a graphical Bash PS1 Generator using Javascript. The user can select any color from a palette (jscolor library) for any element they want. The value i'm getting is the RGB represantion of that color. I would like to convert that value to a number between 0-255 so it can be represented in Bash.
Example:
Input: #000000
Output: 0
Input: #FFFFFF
Output: 255
Any other input converted to the closest 8 bit representation
**I checked this post but the answers aren't quite working(I'm getting output 215 for input #FFFFFF).