imagecolorstotal
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorstotal — 取得图像调色板中的颜色数量
返回值
返回指定图像调色板中的颜色数量,真彩色图像为 0。
示例
示例 #1 使用 imagecolorstotal() 获取图像中的颜色总数
<?php
// 创建图像实例
$im = imagecreatefromgif('php.gif');
echo 'Total colors in image: ' . imagecolorstotal($im);
?>以上示例的输出类似于:
Total colors in image: 128
参见
- imagecolorat() - 取得某像素的颜色索引值
- imagecolorsforindex() - 获取索引的颜色
- imageistruecolor() - 检查图像是否为真彩色图像
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
