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