PHP Conference Japan 2024

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();
}

?>

新增註解

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

0
elmer at web-axis dot net
16 年前
這是此函式的範例

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