ฟังก์ชัน imagecolorresolve() หา index ของสีที่ระบุ หรือสีที่ใกล้เคียงที่สุดใน palette
ไวยากรณ์
imagecolorresolve (img, red, green, blue)
พารามิเตอร์
- img: ภาพจาก imagecreatetruecolor()
- red: ค่าสีแดง (0-255)
- green: ค่าสีเขียว (0-255)
- blue: ค่าสีน้ำเงิน (0-255)
คืนค่า
คืน color index
ตัวอย่าง
<?php
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
$colors = array();
$colors[] = imagecolorresolve($img, 120, 0, 190);
$colors[] = imagecolorresolve($img, 110, 0, 140);
$colors[] = imagecolorresolve($img, 120, 190, 0);
print_r($colors);
imagedestroy($img);
?>
ผลลัพธ์
Array ( [0] => 128 [1] => 129 [2] => 130 )