當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP Imagick getImageWhitePoint()用法及代碼示例

Imagick::getImageWhitePoint()函數是PHP中的一個內置函數,用於獲取Imagick對象的色度白點。

用法:

bool Imagick::getImageWhitePoint( void)

參數:該函數不接受任何參數。


返回值:此函數以鍵值x和y的關聯數組形式返回色度白點。

以下示例程序旨在說明PHP中的Imagick::getImageWhitePoint()函數:

示例1:
原始圖片:
https://media.geeksforgeeks.org/wp-content/uploads/geeks-21.png

<?php 
  
// Craeate new imagic object 
$imagick = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png'); 
  
// Getting Length of image 
// using getimagerelength function 
$res = $imagick->getImageWhitePoint(); 
  
// Display result 
print_r($res); 
  
?>

輸出:

Array ( [x] => 0.31270000338554 [y] => 0.3289999961853 ) 

示例2:
原始圖片:
https://media.geeksforgeeks.org/wp-content/uploads/Screenshot-from-2018-10-16-23-23-54.png

<?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); 
  
// getting Length of image 
// using getimagerelength function 
$res = $im->getImageWhitePoint(); 
  
// Display result 
print_r($res); 
  
?>

輸出:

Array ( [x] => 0.31270000338554 [y] => 0.3289999961853 ) 

參考: http://php.net/manual/en/imagick.getimagewhitepoint.php



相關用法


注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | Imagick getImageWhitePoint() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。