Get the html color from a picture

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Get the html color from a picture

Post by psychotomus »

I wish to get the html color of a picture say and co-ords 0,0 top left pixel?

is this possible? if so, what function would I use?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The image functions would prove useful here....
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

I browsed threw them all.

I closest thing I found was

http://us2.php.net/manual/en/function.imagecolorat.php


but that only returns the RGB values and not HTML values. How can I convert the RGB values to an HTML value?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

psychotomus wrote:but that only returns the RGB values and not HTML values. How can I convert the RGB values to an HTML value?
"HTML values" are actually hex values. Hex is base 16. Decimal (regular numbers) is base 10.

What you want to do is convert the decimal RGB value to a hex RGB value. You can use dechex() to do the conversion for you, and then just concatenate the three hex values together as a string.
Post Reply