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


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

Imagick::uniqueImageColors()函數是PHP中的內置函數,用於丟棄任何像素顏色以外的所有像素顏色。此函數在6.2.9版或更高版本中可用。

用法:

bool Imagick::uniqueImageColors( void )

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


返回值:成功時此函數返回True。

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

程序:

<?php 
  
// Create an Imagick object 
$imagick = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); 
  
// Reduce the image to 256 colours nicely. 
$imagick->quantizeImage(256, \Imagick::COLORSPACE_YIQ, 0, false, false); 
  
// Use uniqueImageColors function to distinguish the color of image 
$imagick->uniqueImageColors(); 
  
// Scale the output image 
$imagick->scaleimage($imagick->getImageWidth() * 10,  
              $imagick->getImageHeight() * 50); 
header("Content-Type: image/png"); 
  
// Display the output image 
echo $imagick->getImageBlob(); 
?>

輸出:
unique image colors

相關文章:

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



相關用法


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