PHP Conference Japan 2024

Imagick::unsharpMaskImage

(PECL imagick 2, PECL imagick 3)

Imagick::unsharpMaskImage銳化影像

說明

public Imagick::unsharpMaskImage(
    float $radius,
    float $sigma,
    float $amount,
    float $threshold,
    int $channel = Imagick::CHANNEL_DEFAULT
): bool

銳化影像。我們使用給定半徑和標準差 (sigma) 的高斯運算子對影像進行捲積。為了獲得合理的效果,半徑應該大於 sigma。使用半徑 0,Imagick::UnsharpMaskImage() 會為您選擇合適的半徑。

參數

radius

sigma

amount

threshold

channel

回傳值

成功時回傳 true

錯誤/例外

發生錯誤時拋出 ImagickException。

範例

範例 #1 Imagick::unsharpMaskImage()

<?php
function unsharpMaskImage($imagePath, $radius, $sigma, $amount, $unsharpThreshold) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->unsharpMaskImage($radius, $sigma, $amount, $unsharpThreshold);
header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();
}

?>

新增註解

使用者貢獻的註解 1 則註解

2
匿名
15 年前
準備用於網路的照片

<?php
$im
= new Imagick($SrcFile);

$im->resizeImage ( $Width, $Height , Imagick::FILTER_QUADRATIC , 1 );

$im->normalizeImage();
$im->unsharpMaskImage(0 , 0.5 , 1 , 0.05);

$im->setImageFormat( "jpg" );
$im->setCompressionQuality(75);

$im->writeImage( $OutFile );

$im->removeImage();
?>
To Top