imageistruecolor()函數是PHP中的內置函數,用於查找圖像是否為true-color圖像。 true-color圖像是其中每個像素由三個值(即RGB)指定的圖像。
用法:
bool imageistruecolor( resource $image )
參數:該函數接受單個參數$image來保存圖像。
返回值:如果圖像為真彩色或在其他情況下為FALSE,則此函數返回TRUE。
下麵給出的程序說明了PHP中的imageistruecolor()函數:
程序1:
<?php
// Create an image instance with a truecolor image
$im = imagecreatefrompng(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Check if image is truecolor
$istruecolor = imageistruecolor($im);
// Show the output to browser
if($istruecolor) {
echo "The image is true color";
}
?>
輸出:
The image is true color
程序2:
<?php
// Create an image instance with a grayscale image
$im = imagecreatefrompng(
'https://media.geeksforgeeks.org/wp-content/uploads/20200124094548/grayscaleimage.png');
// Check if image is truecolor
$istruecolor = imageistruecolor($im);
// Show the output to browser
if(!$istruecolor) {
echo "The image is not true color";
}
?>
輸出:
The image is not true color
參考: https://www.php.net/manual/en/function.imageistruecolor.php
相關用法
- PHP pi( )用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- p5.js nfp()用法及代碼示例
- d3.js d3.max()用法及代碼示例
- p5.js str()用法及代碼示例
- PHP Ds\Map xor()用法及代碼示例
- p5.js hex()用法及代碼示例
- p5.js hue()用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js value()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | imageistruecolor() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。