How to detect the main colors of a picture by php
This article is about how php detects the main colors of pictures. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The specific implementation methods are as follows:
$I = imagecreatefromjpeg ("image.jpg"); for ($rgb > > & 0xFF; $g = ($rgb > > & 0xFF; $b = $rgb & 0xFF; $rTotal + = $r; $gTotal + = $g; $bTotal + = $b; $total++;}} $rAverage = round ($rTotal/$total); $gAverage = round ($gTotal/$total); $bAverage = round ($bTotal/$total); Thank you for reading! This is the end of this article on "how to detect the main colors of pictures in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!