CakeFest 2024: The Official CakePHP Conference

Imagick::whiteThresholdImage

(PECL imagick 2, PECL imagick 3)

Imagick::whiteThresholdImage閾値に満たないすべてのピクセルを白にする

説明

public Imagick::whiteThresholdImage(mixed $threshold): bool

Imagick::thresholdImage() と似ていますが、 これは閾値に満たないピクセルをすべて白にし、その他のピクセルはそのままにします。

パラメータ

threshold

戻り値

成功した場合に true を返します。

変更履歴

バージョン 説明
PECL imagick 2.1.0 色を表す文字列をパラメータとして指定できるようになりました。 これまでのバージョンでは ImagickPixel オブジェクトしか指定できませんでした。

例1 Imagick::whiteThresholdImage()

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

?>

add a note

User Contributed Notes 1 note

up
0
elmer at web-axis dot net
15 years ago
Here's a example of this function:

<?php
$img
= new Imagick();
$img->readImage($image_file_name);
$img->whiteThresholdImage('grey');
$img->writeImage($thumb_file_name);
$img->clear();
$img->destroy();
?>
To Top