(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));
    $im = $tc;
    $tc = NULL;
    // 或者使用 imagepalettetotruecolor()
}
// 继续使用图像实例
?>