PHP - get color name from rgb

Now I am working with the GD library in PHP and I am trying to get the name of the color of the pixel, I mean: green, red, blue, etc.

I get the color this way:

$rgb = ImageColorAt($image, $X, $y);
$r = ($rgb >> 16) & 0xFF ;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;

Now, as I can find this color, it is green light, blue, ordinary blue or red, etc.

+5
source share
2 answers

you need to create an associative array that displays value => colorname (or vice versa). fill this array with the data in this table: http://en.wikipedia.org/wiki/Web_colors

then you can search for color names that are also available in CSS. Alternatively, you can add more colornames yourself

+4
source

, ?
16 ^ 6 > 16,7 .

, .
( rgb = > )

+2

All Articles