PHP Gmagick getimagedepth () Function

PHP

Syntax:
int Gmagick::getimagedepth (void)
Parameters:this function takes no parameters.Return value:this function returns the depth of the image.The following programs illustrate the Gmagick::getimagedepth() functionin PHP:Original Image 1:
Program 1:  
// require_once (' vendor / autoload.php ');  
// Create a Gmagick object $image =  new Gmagick ( ' https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-15.png ' );  
// Use the getimagedepth function to calculate the image depth $height = $image -> getimagedepth();  
// Display the depth of the image print_r ( $height ); ?>
Output:
8
Original Image 2:
Program 2: $string = "Computer Science portal for Geeks!" ;  
// Create a new image of the above line // and add color and background $im = new Gmagick(); $draw = new GmagickDraw();  
// Fill the color in the 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 image $im -> drawImage ( $draw ); $im -> setImageFormat ( ' jpeg' ); $dpth = $im -> getimagedepth();  
// Display the depth of the image print_r ( $dpth ); ?>
Output:
8
Link: http : //php.net/manual/en/gmagick.getimagedepth.php



Get Solution for free from DataCamp guru