ImagickPixel::getHSL()函數是PHP中的內置函數,用於獲取ImagickPixel對象描述的歸一化的HSL顏色,每個都是0到1之間的浮點數。HSL代表色相,飽和度和亮度。通常,色相決定像素的顏色,而飽和度決定顏色的強度,光度決定顏色是暗淡還是明亮。
用法:
array ImagickPixel::getHSL( void )
參數:此函數不接受任何參數。
返回值:此函數返回包含HSL值的數組值。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickPixel::getHSL()函數:程序1:
<?php
// Create a new imagickPixel object
$imagickPixel = new ImagickPixel('#d4a62a');
// Get the HSL
$hsl = $imagickPixel->getHSL();
print("<pre>".print_r($hsl, true)."</pre>");
?>
輸出:
Array ( [hue] => 0.12156862745098 [saturation] => 0.66929133858268 [luminosity] => 0.49803921568627 )
程序2:
<?php
// Create a new imagickPixel object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Get the image histogram
$histogramElements = $imagick->getImageHistogram();
// Get the 300th pixel
$getPixel = $histogramElements[300];
// Get the HSL
$hsl = $getPixel->getHSL();
print("<pre>".print_r($hsl, true)."</pre>");
?>
輸出:
Array ( [hue] => 0.54583333333333 [saturation] => 0.29850746268657 [luminosity] => 0.26274509803922 )
參考: https://www.php.net/manual/en/imagickpixel.gethsl.php
相關用法
- PHP ImagickPixel setColorValue()用法及代碼示例
- PHP ImagickPixel setColorValueQuantum()用法及代碼示例
- PHP ImagickPixel isSimilar()用法及代碼示例
- PHP ImagickPixel getColor()用法及代碼示例
- PHP ImagickPixel getColorQuantum()用法及代碼示例
- PHP ImagickPixel setColor()用法及代碼示例
- PHP ImagickPixel isPixelSimilarQuantum()用法及代碼示例
- PHP ImagickPixel __construct()用法及代碼示例
- PHP ImagickPixel getIndex()用法及代碼示例
- PHP ImagickPixel getColorCount()用法及代碼示例
- PHP ImagickPixel setHSL()用法及代碼示例
- PHP ImagickPixel getColorValueQuantum()用法及代碼示例
- PHP ImagickPixel getColorAsString()用法及代碼示例
- PHP ImagickPixel setIndex()用法及代碼示例
- PHP ImagickPixel getColorValue()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickPixel getHSL() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。