PHP imagecolorsforindex - made colors for an index
imagecolorsforindex - made colors for an index.
grammar
array imagecolorsforindex ( resource $image , int $index )
This function returns a having a red, associative array keys in green, blue and alpha, including the corresponding value of the specified color index.
Examples
<?php // 打开一幅图像 $im = imagecreatefrompng('w3big-logo.png'); // 取得一点的颜色 $start_x = 40; $start_y = 20; $color_index = imagecolorat($im, $start_x, $start_y); // 使其可读 $color_tran = imagecolorsforindex($im, $color_index); // 显示该颜色的值 print_r($color_tran); ?>
Output similar to the above example:
Array ( [red] => 195 [green] => 223 [blue] => 165 [alpha] => 64 )
related articles
- imagecolorat () to obtain an index value of a color pixel.
- imagecolorexact () Get the index of the specified color.