getQuantumRange() 在這裡可能很有用
<?php
$i = new Imagick($imageFile);
$max = $i->getQuantumRange();
$max = $max["quantumRangeLong"];
$i->thresholdImage(0.77 * $max);
?>
(PECL imagick 2, PECL imagick 3)
Imagick::thresholdImage — 根據閾值變更個別像素的值
根據每個像素的強度與閾值的比較,變更個別像素的值。結果是高對比的雙色影像。
threshold
channel
成功時回傳 true
。
範例 #1 Imagick::thresholdImage()
<?php
function thresholdimage($imagePath, $threshold, $channel) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->thresholdimage($threshold * \Imagick::getQuantum(), $channel);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>
getQuantumRange() 在這裡可能很有用
<?php
$i = new Imagick($imageFile);
$max = $i->getQuantumRange();
$max = $max["quantumRangeLong"];
$i->thresholdImage(0.77 * $max);
?>