PHP | imagecolorstotal()函数

这个 imagecolorstotal() 函数是PHP中的一个内置函数,用于查找图像调色板中的颜色数。此函数用于返回图像调色板中的颜色数。

null

语法:

int imagecolorstotal ( $image )

参数: 此函数只接受一个参数 $image 这是强制性的。函数用于创建给定大小的图像。此函数用于创建给定大小的空白图像。

返回值: 此函数用于返回给定图像调色板中的颜色数,对于truecolor图像,返回0。

下面的程序说明了 imagecolorstotal() PHP中的函数:

项目1:

<?php
// store the image in variable.
$image = imagecreatefrompng(
echo 'Colors in image: ' . imagecolorstotal( $image );
// Free image
imagedestroy( $image );
?>


输出:

Colors in image: 0

项目2:

<?php
// store the image in variable.
$image = imagecreatefromgif(
echo 'Colors in image: ' . imagecolorstotal( $image );
// Free image
imagedestroy( $image );
?>


输出:

Colors in image: 187

相关文章:

参考: http://php.net/manual/en/function.imagecolorstotal.php

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享