這是此函式的範例
<?php
$img = new Imagick();
$img->readImage($image_file_name);
$img->whiteThresholdImage('grey');
$img->writeImage($thumb_file_name);
$img->clear();
$img->destroy();
?>
(PECL imagick 2, PECL imagick 3)
Imagick::whiteThresholdImage — 強制將所有高於臨界值的像素變成白色
類似 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();
}
?>
這是此函式的範例
<?php
$img = new Imagick();
$img->readImage($image_file_name);
$img->whiteThresholdImage('grey');
$img->writeImage($thumb_file_name);
$img->clear();
$img->destroy();
?>