+

PHP Gmagick getimageformat () Function

Syntax:
string Gmagick::getimageformat (void)
Parameters:this function takes no parameters.Return value:this function returns the image format as a string on success.The following programs illustrate the function Gmagick::getimageformat()in PHP:Original Image 1:

Program 1:
// require_once (` path / vendor / autoload.php `); 
// Create a Gmagick object $image = new  Gmagick ( ` https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-15.png ` );  
// Use the getimageformat function to find
// image formats $res = $image -> getimageformat() ;  
// Show image formatting sequence echo $res ; ?>
Output:
PNG
Original image 2:
Program 2: $string = "Computer Science portal for Geeks!" ;  
// create a new image above the 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` );  
// Gmagick function to get the format of the generated image $res = $im -> getimageformat();  
// Display the image format echo $res ; ?>
Output:
jpeg
Link: http : //php.net/manual/en/gmagick.getimageformat.php
Get Solution for free from DataCamp guru