imagecolorsforindex() फंक्शन इंडेक्स के लिए रंग प्राप्त करता है।
सिंटैक्स
imagecolorsforindex ( img, index )
पैरामीटर्स
img: imagecreatetruecolor() के साथ इमेज बनाता है
Index: कलर इंडेक्स सेट करता है।
रिटर्न
imagecolorsforindex() फंक्शन एक एसोसिएटिव ऐरे लौटाता है जिसमें लाल, हरा, नीला और अल्फा कीज़ होती हैं जिनमें निर्दिष्ट कलर इंडेक्स के लिए उपयुक्त मान होते हैं।
उदाहरण
निम्नलिखित एक उदाहरण है
<?php
$img = imagecreatefrompng('https://www.tutorialspoint.com/images/tp-logo-diamond.png');
$x = 25;
$y = 45;
$rgb = imagecolorat($img, 25, 45);
$colors = imagecolorsforindex($img, $rgb);
var_dump($colors);
?>
आउटपुट
निम्नलिखित आउटपुट है:
array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }