PHP | Gmagick setimagechanneldepth() Function Last Updated : 29 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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: $channel: This parameter is used to specify the channel constant. Below is the list of constant channel: CHANNEL constants: Gmagick::CHANNEL_UNDEFINED Gmagick::CHANNEL_RED Gmagick::CHANNEL_GRAY Gmagick::CHANNEL_CYAN Gmagick::CHANNEL_GREEN Gmagick::CHANNEL_MAGENTA Gmagick::CHANNEL_BLUE Gmagick::CHANNEL_YELLOW Gmagick::CHANNEL_ALPHA Gmagick::CHANNEL_OPACITY Gmagick::CHANNEL_MATTE Gmagick::CHANNEL_BLACK Gmagick::CHANNEL_INDEX Gmagick::CHANNEL_ALL Gmagick::CHANNEL_DEFAULT $depth: This parameter is used to specify the depth to be set for Gmagick object. Return Value: This function returns the Gmagick object on success. Below programs illustrate the Gmagick::setimagechanneldepth() function in PHP: Program 1: Original Image: php <?php // Create new Gmagick object $im = new Gmagick( '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(Gmagick::CHANNEL_RED) . "</br>"; // Set channel Depth of CYAN and GREEN Channel $im->setimagechanneldepth(Gmagick::CHANNEL_RED, 4); echo "After Set Channel depth: " . "</br>"; echo $im->getImageChannelDepth(Gmagick::CHANNEL_RED) . "</br>"; ?> Output: Before Set Channel depth: 8 After Set Channel depth: 4 Program 2: Original Image: php <?php $string = "Computer Science portal for Geeks!"; // Creating new image of above String // and add color $im = new Gmagick(); $draw = new GmagickDraw(); // Fill the color in image $draw->setFillColor(new GmagickPixel('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 GmagickPixel('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(Gmagick::CHANNEL_GREEN) . "</br>"; // Set channel Depth of Green Channel $im->setimagechanneldepth(Gmagick::CHANNEL_GREEN, 8); echo "After Set Channel depth: " . "</br>"; echo $im->getImageChannelDepth(Gmagick::CHANNEL_GREEN) . "</br>"; ?> Output: Before Set Channel depth: 16 After Set Channel depth: 8 Reference: http://php.net/manual/en/gmagick.setimagechanneldepth.php Comment More infoAdvertise with us Next Article PHP | Gmagick setimagechanneldepth() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP Image-Processing PHP-function PHP-Gmagick +1 More Similar Reads PHP | Imagick setImageChannelDepth() Function 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: T 2 min read PHP | Gmagick setimagedepth() function The Gmagick::setimagedepth() function is an inbuilt function in PHP which is used to set the depth of a particular image. Syntax: Gmagick Gmagick::setimagedepth( $depth ) Parameters: This function accepts a single parameter $depth which is an integer value and used to set the depth of image. Return 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 | Gmagick setimageunits() Function The Gmagick::setimageunits() function is an inbuilt function in PHP which is used to set the units of resolution of a particular image. This function has no visual impact on the image but just changes the units of resolution which can be one of Undefinedresolution, PixelsPerInchResolution, or Pixels 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 Like