HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::rangeThresholdImage

← randomThresholdImage   readImageBlob →
Some colours go black...others go white, some remain the same.

Example

function rangeThresholdImage(
    $image_path,
    float $low_black,
    float $low_white,
    float $high_white,
    float $high_black
) {
    $imagick = new \Imagick(realpath($image_path));
    $imagick->rangeThresholdImage(
        $low_black * \Imagick::getQuantum(),
        $low_white * \Imagick::getQuantum(),
        $high_white * \Imagick::getQuantum(),
        $high_black * \Imagick::getQuantum()
    );
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}