PHP | Imagick getImageFormat() Function
Last Updated :
06 Oct, 2021
The Imagick::getImageFormat() function is an inbuilt function in PHP which is used to get the format of a particular image in a sequence
Syntax:
string Imagick::getImageFormat( void )
Parameters: This function does not accepts any parameter.
Return Value: This function returns a string of the image format on success.
Below program illustrates the Imagick::getImageFormat() function in PHP:
Program 1:
Original Image:
php
<?php
$image = new Imagick(
$res = $image ->getImageFormat();
echo $res ;
?>
|
Output:
PNG
Program 2:
php
<?php
$string = "Computer Science portal for Geeks!" ;
$im = new Imagick();
$draw = new ImagickDraw();
$draw ->setFillColor( new ImagickPixel( 'green' ));
$draw ->setFontSize(50);
$matrix = $im ->queryFontMetrics( $draw , $string );
$draw ->annotation(0, 40, $string );
$im ->newImage( $matrix [ 'textWidth' ], $matrix [ 'textHeight' ],
new ImagickPixel( 'white' ));
$im ->drawImage( $draw );
$im ->setImageFormat( 'jpeg' );
$res = $im ->getImageFormat();
echo $res ;
?>
|
Output:
jpeg
Reference: http://php.net/manual/en/imagick.getimageformat.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...