imageistruecolor() เป็นฟังก์ชัน inbuilt ใน PHP ที่ใช้ในการตรวจสอบว่ารูปภาพที่กำหนดเป็นรูปภาพที่มีสีจริงหรือไม่ ในภาพสีจริง แต่ละพิกเซลถูกกำหนดโดยค่าสี RGB (แดง เขียว และน้ำเงิน)
ไวยากรณ์
bool imageistruecolor(resource $image)
พารามิเตอร์
imageistruecolor() รับพารามิเตอร์ตัวเดียว $image . มันเก็บภาพไว้
คืนค่า
imageistruecolor() คืนค่า True หากรูปภาพที่กำหนดเป็นสีจริงหรืออย่างอื่น จะคืนค่า False หากรูปภาพไม่ใช่รูปภาพที่มีสีจริง
ตัวอย่างที่ 1
<?php
// Create an image instance with a true-color image using
//imagecreatefrompng() function.
$img = imagecreatefrompng('C:\xampp\htdocs\Images\img44.png');
// Checked if the image is true-color
$istruecolor = imageistruecolor($img);
// Show the output image to the browser
if($istruecolor) {
echo "The given input image is true-color";
}
?> ผลลัพธ์
// ป้อนภาพ RGB

// ผลลัพธ์ที่ได้
The given input image is true-color.
ตัวอย่างที่ 2
<?php
// Create an image instance with a true-color image using
//imagecreatefrompng() function.
$img = imagecreatefrompng('C:\xampp\htdocs\Gray.png');
// Checked if the image is true-color
$istruecolor = imageistruecolor($img);
// Show the output image to the browser
if($istruecolor) {
echo "The given input image is not a true-color";
}
?> ผลลัพธ์
// อินพุตรูปภาพสีเทา

// เอาท์พุต
The given input image is not a true-color image.