Imagick::getImageResolution()函數是PHP中的內置函數,用於獲取圖像對象的分辨率。
用法:
bool Imagick::getImageResolution( void)
參數:該函數不接受任何參數。
返回值:此函數以數組形式返回分辨率。
以下示例程序旨在說明PHP中的Imagick::getImageResolution()函數:
示例1:
原始圖片:
<?php
// Create an imagick image object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png');
// Getting Resolution of created image
// using getimageresolution function
$res = $im->getImageResolution();
echo "X = ".$res['x'] . "</br>";
echo "Y = ".$res['y'] ." </br>";
?>
輸出:
X = 37.8 Y = 37.8
示例2:
原始圖片:
<?php
$string = "Computer Science portal for Geeks!";
// Creating new image of above String
// and add color and background
$im = new Imagick();
$draw = new ImagickDraw();
// Fill the color in image
$draw->setFillColor(new ImagickPixel('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 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'] . "</br>";
echo "Y = ".$res['y'] ." </br>";
?>
輸出:
X = 50 Y = 50
參考: http://php.net/manual/en/imagick.getimageresolution.php
相關用法
- PHP Gmagick getimageresolution()用法及代碼示例
- PHP Imagick stripImage()用法及代碼示例
- PHP Imagick setImageColorspace()用法及代碼示例
- PHP Imagick setImageScene()用法及代碼示例
- PHP Imagick setImageWhitePoint()用法及代碼示例
- PHP Imagick medianFilterImage()用法及代碼示例
- PHP Imagick separateImageChannel()用法及代碼示例
- PHP Imagick sepiaToneImage()用法及代碼示例
- PHP Imagick readImages()用法及代碼示例
- PHP Imagick getImageRedPrimary()用法及代碼示例
- PHP Imagick blueShiftImage()用法及代碼示例
- PHP Imagick readImage()用法及代碼示例
- PHP Imagick readImageFile()用法及代碼示例
- PHP Imagick remapImage()用法及代碼示例
- PHP Imagick setColorspace()用法及代碼示例
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | Imagick getImageResolution() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。