- <?php
- function getRgbimg($dec)
- {
- return strtoupper($dec>15?dechex($dec):('0'.dechex($dec)));
- }
- $im = imagecreatefromjpeg('11.jpg');
- $rgb = imagecolorat($im,500,0);
- $r = ($rgb >> 16) & 0xFF;
- $g = ($rgb >> 8) & 0xFF;
- $b = $rgb & 0xFF;
- $RGB = getRgbimg($r).getRgbimg($g).getRgbimg($b);
- echo "dec:$r-$g-$b<br />hex:#$RGB";
- echo '<div style="background-color:#'.$RGB.'; height:100px; height:100px"></div>';
- ?>