PHP 中的 imagecolorstotal() 函数

phpserver side programmingprogramming

imagecolorstotal() 函数获取图像调色板中的颜色数量

语法

imagecolorstotal (img)

参数

  • img:使用 imagecreatetruecolor() 创建的图像。

返回值

imagecolorstotal() 函数返回图像调色板中的颜色数量。

示例

以下是示例

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   echo 'Number of Colors = ' . imagecolorstotal($img);
   imagedestroy($img);
?>

输出

输出结果如下:

Number of Colors = 128

相关文章