(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)
imageistruecolor — 查找图像是否为真彩色图像
示例 #1 使用 imageistruecolor() 简单检测真彩色图像实例
<?php
// $im 是一个图像实例
// 检查图像是否为真彩色图像
if(!imageistruecolor($im))
{
 // 创建一个新的真彩色图像实例
 $tc = imagecreatetruecolor(imagesx($im), imagesy($im));
 // 复制像素
 imagecopy($tc, $im, 0, 0, 0, 0, imagesx($im), imagesy($im));
 imagedestroy($im);
 $im = $tc;
 $tc = NULL;
 // 或者使用 imagepalettetotruecolor()
}
// 继续使用图像实例
?>