PHP | Gmagick getimageformat() Function
Last Updated :
28 Aug, 2019
The Gmagick::getimageformat() function is an inbuilt function in PHP which returns the format of an image.
Syntax:
string Gmagick::getimageformat( void )
Parameters: This function does not accepts any parameter.
Return Value: This function returns the image format in form of string on success.
Below programs illustrate the Gmagick::getimageformat() function in PHP:
Original Image 1:
Program 1:
<?php
$image = new Gmagick(
$res = $image ->getimageformat();
echo $res ;
?>
|
Output:
PNG
Original Image 2:
Program 2:
<?php
$string = "Computer Science portal for Geeks!" ;
$im = new Gmagick();
$draw = new GmagickDraw();
$draw ->setFillColor( new GmagickPixel( 'green' ));
$draw ->setFontSize(50);
$metrix = $im ->queryFontMetrics( $draw , $string );
$draw ->annotation(0, 40, $string );
$im ->newImage( $metrix [ 'textWidth' ], $metrix [ 'textHeight' ],
new GmagickPixel( 'white' ));
$im ->drawImage( $draw );
$im ->setImageFormat( 'jpeg' );
$res = $im ->getimageformat();
echo $res ;
?>
|
Output:
jpeg
Reference: http://php.net/manual/en/gmagick.getimageformat.php
Share your thoughts in the comments
Please Login to comment...