PHP | Imagick setImageChannelDepth() Function Last Updated : 26 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Imagick::setImageChannelDepth() function is an inbuilt function in PHP which is used to set the depth of a particular channel image. Syntax: bool Imagick::setImageChannelDepth( $channel, $depth ) Parameters: This function accepts two parameters as mentioned above and described below: $channel: This parameter is used to specify the channel constant. Below is the list of constant channel: CHANNEL constants: imagick::CHANNEL_UNDEFINED imagick::CHANNEL_RED imagick::CHANNEL_GRAY imagick::CHANNEL_CYAN imagick::CHANNEL_GREEN imagick::CHANNEL_MAGENTA imagick::CHANNEL_BLUE imagick::CHANNEL_YELLOW imagick::CHANNEL_ALPHA imagick::CHANNEL_OPACITY imagick::CHANNEL_MATTE imagick::CHANNEL_BLACK imagick::CHANNEL_INDEX imagick::CHANNEL_ALL imagick::CHANNEL_DEFAULT $depth: This parameter is used to specify the depth to be set for Imagick object. Return Value: This function returns True on success. Below programs illustrate the Imagick::setImageChannelDepth() function in PHP: Original Image: Program 1: php <?php // Create new Imagick object $im = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png'); // Using getImageChannelDepth function // with red channel echo "Before Set Channel depth: " . "</br>"; echo $im->getImageChannelDepth(imagick::CHANNEL_RED) . "</br>"; // Set channel Depth of CYAN and GREEN Channel $im->setImageChannelDepth(imagick::CHANNEL_RED, 4); echo "After Set Channel depth: " . "</br>"; echo $im->getImageChannelDepth(imagick::CHANNEL_RED) . "</br>"; ?> Output: Before Set Channel depth: 8 After Set Channel depth: 4 Original Image: Program 2: php <?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 red channel echo "Before Set Channel depth: " . "</br>"; echo $im->getImageChannelDepth(imagick::CHANNEL_GREEN) . "</br>"; // Set channel Depth of Green Channel $im->setImageChannelDepth(imagick::CHANNEL_GREEN, 8); echo "After Set Channel depth: " . "</br>"; echo $im->getImageChannelDepth(imagick::CHANNEL_GREEN) . "</br>"; ?> Output: Before Set Channel depth: 16 After Set Channel depth: 8 Reference: http://php.net/manual/en/imagick.setimagechanneldepth.php Comment More infoAdvertise with us Next Article PHP | Imagick setImageChannelDepth() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP Image-Processing PHP-function PHP-Imagick +1 More Similar Reads PHP | Gmagick setimagechanneldepth() Function The Gmagick::setimagechanneldepth() function is an inbuilt function in PHP which is used to set the depth of a particular channel image. Syntax: Gmagick Gmagick::setimagechanneldepth( $channel , $depth ) Parameters: This function accepts two parameters as mentioned above and described below: $channe 2 min read PHP | Imagick setImageDepth() Function The Imagick::setImageDepth() function is an inbuilt function in PHP which is used to set the depth of a particular image.Syntax:Â Â bool Imagick::setImageDepth( $depth ) Parameters: This function accepts a single parameter $depth which is an integer value and used to set the depth of image.Return Val 2 min read PHP | Imagick separateImageChannel() function The Imagick::separateImageChannel() function is an inbuilt function in PHP which is used to separate a channel from the image and returns a grayscale image. A channel is a particular color component of each pixel in the image. Syntax: bool Imagick::separateImageChannel( int $channel ) Parameters:Thi 1 min read PHP | Imagick setImageScene() Function The Imagick::setImageScene() function is an inbuilt function in PHP which is used to set the image scene. The value of scene contains an integer value. Syntax: bool Imagick::setImageScene( int $scene ) Parameters: This function accepts a single parameter $scene which holds the scene. Return Value: T 1 min read PHP | Imagick setImagePage() Function The Imagick::setImagePage() function is an inbuilt function in PHP which is used to set the image page geometry. Syntax: bool Imagick::setImagePage(int $width, int $height, int $x, int $y ) Parameters: This function accepts four parameters as mentioned above and described below: $width: It specifies 1 min read Like