Imagick::getImageChannelDepth()函数是PHP中的内置函数,用于获取通道图像的深度。
用法:
int Imagick::getImageChannelDepth( $channel )
参数:该函数接受单个参数$channel,该参数指定对通道模式有效的通道常数。频道的默认值为Imagick::CHANNEL_DEFAULT。
返回值:成功时此函数返回True。
以下示例程序旨在说明PHP中的Imagick::getImageChannelDepth()函数:
程序1:
原始图片:
<?php
// Create new imagick object
$im = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png');
// Using getImageChannelDepth function
// with different channel
echo $im->getImageChannelDepth(imagick::CHANNEL_RED) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_GRAY) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_CYAN) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_GREEN) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_BLUE) . "</br>";
?>
输出:
8 8 8 8 8
程序2:
原始图片:
<?php
$string = "Computer Science portal for Geeks!";
// Creating new image of above String
// and add color
$im = new Imagick();
$draw = new ImagickDraw();
// Fill the color in image
$draw->setFillColor(new ImagickPixel('green'));
// Set the text font size
$draw->setFontSize(50);
$metrix = $im->queryFontMetrics($draw, $string);
$draw->annotation(0, 40, $string);
$im->newImage($metrix['textWidth'], $metrix['textHeight'],
new ImagickPixel('white'));
// Draw the image
$im->drawImage($draw);
$im->setImageFormat('jpeg');
// Using getImageChannelDepth function
// with different channel
echo $im->getImageChannelDepth(imagick::CHANNEL_RED) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_GRAY) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_CYAN) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_GREEN) . "</br>";
echo $im->getImageChannelDepth(imagick::CHANNEL_BLUE) . "</br>";
?>
输出:
8 8 8 16 8
参考: http://php.net/manual/en/imagick.getimagechanneldepth.php
相关用法
- PHP Gmagick getimagechanneldepth()用法及代码示例
- PHP Imagick getImageExtrema()用法及代码示例
- PHP Imagick getImageChannelDistortions()用法及代码示例
- PHP Imagick getImageCompression()用法及代码示例
- PHP Imagick setImageCompressionQuality()用法及代码示例
- PHP Imagick getImageDistortion()用法及代码示例
- PHP Imagick getImageCompose()用法及代码示例
- PHP Imagick getImageChannelStatistics()用法及代码示例
- PHP Imagick getImageClipMask()用法及代码示例
- PHP Imagick setImageClipMask()用法及代码示例
- PHP Imagick setImageCompose()用法及代码示例
- PHP Imagick getImageChannelMean()用法及代码示例
- PHP Imagick getImageChannelExtrema()用法及代码示例
- PHP Imagick setImageBorderColor()用法及代码示例
- PHP Imagick morphImages()用法及代码示例
注:本文由纯净天空筛选整理自R_Raj大神的英文原创作品 PHP | Imagick getImageChannelDepth() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。