ฟังก์ชัน imagecolorstotal() นับจำนวนสีใน palette ของภาพ
ไวยากรณ์
imagecolorstotal (img)
พารามิเตอร์
- img: ภาพจาก imagecreatetruecolor()
คืนค่า
จำนวนสีใน palette
ตัวอย่าง
<?php
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
echo 'Number of Colors = ' . imagecolorstotal($img);
imagedestroy($img);
?>
ผลลัพธ์
Number of Colors = 128