imageistruecolor

(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)

imageistruecolor检查图像是否为真彩色图像

说明

imageistruecolor(GdImage$image): bool

imageistruecolor() 检查 image 图像是否为真彩色图像。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。

返回值

如果 image 是真彩色返回 true,否则返回 false

更新日志

版本说明
8.0.0image 现在需要 GdImage 实例;之前需要有效的 gdresource

示例

示例 #1 使用 imageistruecolor() 简单检测真彩色实例

<?php
// $im is an image instance

// Check if image is a true color image or not
if(!imageistruecolor($im))
{
// Create a new true color image instance
$tc = imagecreatetruecolor(imagesx($im), imagesy($im));

// 复制像素
imagecopy($tc, $im, 0, 0, 0, 0, imagesx($im), imagesy($im));
imagedestroy($im);

$im = $tc;
$tc = NULL;

// 或者使用 imagepalettetotruecolor()
}

// Continue working with image instance
?>

参见

To Top