Imagick::paintTransparentImage()函數是PHP中的內置函數,可用於更改與顏色匹配的任何像素和定義的顏色。
用法:
bool Imagick::paintTransparentImage( $target, $alpha, $fuzz )
參數:此函數接受上述和以下所述的三個參數:
- $target:它包含目標顏色的值,以在給定範圍內更改指定的不透明度值。
- $alpha:它包含從0.0(完全透明)到1.0(完全不透明)的浮點值。
- $fuzz:它定義了將兩種顏色視為相同時可接受的公差。
返回值:成功時此函數返回True。
錯誤/異常:此函數在錯誤時引發ImagickException。
以下示例程序旨在說明PHP中的Imagick::paintTransparentImage()函數:
程序:
<?php
// Create a new Imagick object
$imagick = new \Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png');
// Cloning the imagick object
$paintit = clone $imagick;
$quantum = $imagick->getQuantumDepth()['quantumDepthLong'];
// Use Imagick::paintTransparentImage() function function
// change the pixel color
$paintit->paintTransparentImage("White", 0.2, 0.5 *$quantum);
header("Content-Type: image/jpg");
// Display the output image
echo $paintit->getImageBlob();
?>
輸出:
參考: https://www.php.net/manual/en/imagick.painttransparentimage.php
相關用法
- PHP Imagick setImageAlphaChannel()用法及代碼示例
- PHP Imagick getImageChannelStatistics()用法及代碼示例
- PHP Imagick getImageCompose()用法及代碼示例
- PHP Imagick setImageClipMask()用法及代碼示例
- PHP Imagick getImageChannelExtrema()用法及代碼示例
- PHP Imagick getImageChannelMean()用法及代碼示例
- PHP Imagick getImageClipMask()用法及代碼示例
- PHP Imagick setImageBorderColor()用法及代碼示例
- PHP Imagick haldClutImage()用法及代碼示例
- PHP Imagick getImageBackgroundColor()用法及代碼示例
- PHP Imagick getImageChannelDistortion()用法及代碼示例
- PHP Imagick setImageBluePrimary()用法及代碼示例
- PHP Imagick getImageBorderColor()用法及代碼示例
- PHP Imagick setImageBackgroundColor()用法及代碼示例
- PHP Imagick setImageCompose()用法及代碼示例
注:本文由純淨天空篩選整理自harshvvaid1996大神的英文原創作品 PHP | Imagick paintTransparentImage() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。