PHP obtains the image color value. PHP code for obtaining the image color value and checking the main color of the image: viewsourceprint? 0102$iimagecreatefrom((photo3.jpg); test the image and define one by yourself. pay attention to the code for obtaining the image color value in the path 03for ($ PHP and checking the main color of the image:
View sourceprint? 01
02 $ I = imagecreatefromjpeg ("photo3.jpg"); // test the image. define one by yourself. pay attention to the path.
03for ($ x = 0; $ x
04 for ($ y = 0; $ y
05 $ rgb = imagecolorat ($ I, $ x, $ y );
06 $ r = ($ rgb> 16) & 0xFF;
07 $ g = ($ rgb >>& 0xFF;
08 $ B = $ rgb & 0xFF;
09 $ rTotal + = $ r;
10 $ gTotal + = $ g;
11 $ bTotal + = $ B;
12 $ total ++;
13}
14}
15 $ rAverage = round ($ rTotal/$ total );
16 $ gAverage = round ($ gTotal/$ total );
17 $ bAverage = round ($ bTotal/$ total );
18 // example:
19 echo $ rAverage;
20?>
Lateral view sourceprint? 01 02$ I ?imagecreatefrom=(photo3.jpg); // test the image and define one by yourself. Note that the path 03for ($...