I was looking through the GD functions but have not found anything. Any help is appreciated, I do not really mind if the colors returned are in rgb or hex
@ConorauthorApr 03.2005 — #wow can't believe I missed that. Now I just need to write a function that goes through each color and finds two most prominent. It might be tough though for something like an 80 by 80 image thats 6400 pixels of color and I'm almost positive that would time out. Any ideas?
@JonaApr 03.2005 — #[font=trebuchet ms]Look at [url=http://us2.php.net/manual/en/function.imagecolorstotal.php]imagecolorstotal[/url] and the comments therein.[/font]
@ConorauthorApr 03.2005 — #I only saw a couple of comments and I tried this code [code=php] <? $im = imagecreatefromgif('colors.gif'); imagetruecolortopalette($im, false, 256); $colors=imagecolorstotal($im); echo $colors; ?> [/code] but it did not return anything
@JonaApr 03.2005 — #[font=trebuchet ms]That worked for me, but it only gives the total number of colors. It turns out you'll have to loop through the image. This might be a good start:[/font]
@JonaApr 03.2005 — #[font=trebuchet ms]Yeah. I was looking for some sort of built-in array sorting function to do it, but it looks like you'll have to do some math in the second for loop to get what you're after. On a large image, this can take up a ton of processing power and might even freeze up your server for a few minutes, so be careful. I wouldn't advise anything over 400x400 pixels.[/font]
@ConorauthorApr 03.2005 — #sorry to bother you, I just have one last question. What is the key for the array. Its neccasary for me to know that so I can finish up my script.