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... Link to comment https://forums.phpfreaks.com/topic/108011-image-colors-analize/ 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. Link to comment https://forums.phpfreaks.com/topic/108011-image-colors-analize/#findComment-553666 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); ?> Link to comment https://forums.phpfreaks.com/topic/108011-image-colors-analize/#findComment-553822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.