📜  PHP |想象一下 getImageResolution()函数

📅  最后修改于: 2022-05-13 01:56:36.942000             🧑  作者: Mango

PHP |想象一下 getImageResolution()函数

Imagick::getImageResolution()函数是PHP中的一个内置函数,用于获取图像对象的分辨率。

句法:

bool Imagick::getImageResolution( void)

参数:此函数不接受任何参数。

返回值:此函数将分辨率作为数组返回。

下面的程序说明了PHP中的Imagick::getImageResolution()函数:

方案一:
原图:
https://media.geeksforgeeks.org/wp-content/uploads/geeks-21.png

getImageResolution();
echo "X = ".$res['x'] . "
"; echo "Y = ".$res['y'] ."
"; ?>

输出:

X = 37.8
Y = 37.8

方案二:
原图:
https://media.geeksforgeeks.org/wp-content/uploads/Screenshot-from-2018-10-16-23-23-54.png

setFillColor(new ImagickPixel('green')); 
    
// Set the text font size 
$draw->setFontSize(50); 
    
$matrix = $im->queryFontMetrics($draw, $string); 
$draw->annotation(0, 40, $string); 
$im->newImage($matrix['textWidth'], $matrix['textHeight'], 
         new ImagickPixel('white')); 
             
// Draw the image          
$im->drawImage($draw); 
$im->setImageResolution(50, 50); 
  
// getting Resolution of created image
// using getimageresolution function
$res = $im->getImageResolution();
echo "X = ".$res['x'] . "
"; echo "Y = ".$res['y'] ."
"; ?> 

输出:

X = 50
Y = 50 

参考: http: PHP。 PHP