imagecolorsforindex() lấy thành phần RGBA của màu tại một index trong palette.
Cú pháp
imagecolorsforindex(resource $image, int $index): array
Trả về
Mảng kết hợp: ['red'=>int, 'green'=>int, 'blue'=>int, 'alpha'=>int].
Ví dụ
<?php
$img = imagecreatefrompng('https://example.com/logo.png');
$rgb = imagecolorat($img, 25, 45); // lấy color index tại pixel
$colors = imagecolorsforindex($img, $rgb);
var_dump($colors);
// array(4) { ["red"]=>255 ["green"]=>255 ["blue"]=>255 ["alpha"]=>127 }
?>