PHP | Gmagick getimageresolution() Function
Last Updated :
28 Aug, 2019
The Gmagick::getimageresolution() function is an inbuilt function in PHP which is used to get the resolution of an image object.
Syntax:
array Gmagick::getimageresolution( void )
Parameters: This function does not accept any parameter.
Return Value: This function returns the resolution as an array.
Below program illustrates the Gmagick::getimageresolution() function in PHP:
Original Image 1:
Program 1:
<?php
$gmagick = new Gmagick(
$res = $gmagick ->getimageresolution();
echo "X = " . $res [ 'x' ] . "</br>" ;
echo "Y = " . $res [ 'y' ] . " </br>" ;
?>
|
Output:
X = 37.8
Y = 37.8
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 ->setImageResolution(50, 50);
$res = $im ->getimageresolution();
echo "X = " . $res [ 'x' ] . "</br>" ;
echo "Y = " . $res [ 'y' ] . " </br>" ;
?>
|
Output:
X = 50
Y = 50
Reference: http://php.net/manual/en/gmagick.getimageresolution.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...