php检测图片主要颜色的方法_PHP教程

WBOY
Libérer: 2016-07-13 09:47:58
original
845 Les gens l'ont consulté

php检测图片主要颜色的方法

   本文实例讲述了php检测图片主要颜色的方法。分享给大家供大家参考。具体实现方法如下:

  ?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

$i = imagecreatefromjpeg("image.jpg");

for ($x=0;$x

for ($y=0;$y

$rgb = imagecolorat($i,$x,$y);

$r = ($rgb >> 16) & 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);

  希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1025321.htmlTechArticlephp检测图片主要颜色的方法 本文实例讲述了php检测图片主要颜色的方法。分享给大家供大家参考。具体实现方法如下: ? 1 2 3 4 5 6 7 8 9 10...
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!