Jet-J Posted May 30, 2008 Share Posted May 30, 2008 Hello... I want to make this functionality.... I need to read colors from image to get which color is most biggest by proccent... Example.... Please click on COLOR RED (for example) to see result... http://images.yandex.ru/yandsearch?icolor=...s&rpt=image TNX... Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted May 30, 2008 Share Posted May 30, 2008 I would say go with JAVASCRIPT. I don't know any scripts my self but GOOGLE it. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 30, 2008 Share Posted May 30, 2008 count colours, pixel by pixel <?php $im = imagecreatefrompng('myfile.png'); $ccount = array(); for ($x=0, $w = imagesx($im); $x < $w; $x++) { for ($y=0, $h = imagesy($im); $y < $h; $y++) { $c = imagecolorat($im, $x, $y); $a = imagecolorsforindex($im, $c); $ccount[vsprintf('%02X%02X%02X', $a)]++; } } $max = max($ccount); $sum = array_sum($ccount); $mostused = array_search($max, $ccount); $pcent = $max*100/$sum; printf ('Most used #%s : %0.2f%%', $mostused, $pcent); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.