PHP 中的 imagecolorstotal() 函数


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

语法

imagecolorstotal (img)

参数

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

返回

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

示例

以下是一个示例

 实战演示

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

输出

以下为输出

Number of Colors = 128

更新于: 2019 年 12 月 31 日

43 次浏览

开启你的 职业生涯

完成课程即可获得认证

开始学习
广告
© . All rights reserved.