5

i work now with GD library on PHP and i'm trying to get the pixel color name ,i mean : green , red , blue , etc...

i'm getting the color this way :

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

now , how can i find it this color is green light , dark blue , normal blue or red and etc..

1
  • 1
    The color names you give, to which palette do they belong to? Are they defined somewhere? Commented Sep 29, 2011 at 16:53

2 Answers 2

4

you have to create an associative-array that maps value => colorname (or inverse). fill this array with the data of this table: http://en.wikipedia.org/wiki/Web_colors

then you can lookup the color names, that are available in CSS too. additionally you can add more, own, colornames

Sign up to request clarification or add additional context in comments.

2 Comments

Please don't reference w3school, it's a terrible resource, reasons can be found @ the lin Marc B provided.
i didn´t knew this. one of my professors of my university referes to w3schools too... corrected
2

Are you suppose that every color has its own name?
It's 16^6>16.7 millions.

So, it seems to be impossible.
But you may create your own database (format rgb => human-readable)

3 Comments

so - 1 image 10,000 pixels = 10,000 query ? i don't think so! but thanks.
@Mor Sela: RiaD is referring to 16.7 millions color names. You have only named four and you haven't even given the URL of that list.
I think you haven't 10.000 different colors in every page if you need to name it. So, you can group pixedl by color. Besides, You can try to group it by for example only first digit for every component. I'e 00-0F,10-1F

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.