Get the App
SLTechnology News&Howtos  ›  Development  › 

How to detect the main colors of a picture by php

Shulou Source: shulou.com Published: 2022-06-03 19:41:28 11月12日 Update

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!

Tags: Pictures colors tests content more articles good practical articles methods look knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS Xiaomi MariaDB Linux