function adaptiveThresholdImage($image_path, $width, $height, $adaptiveOffset) { $imagick = new \Imagick(realpath($image_path)); $adaptiveOffsetQuantum = intval($adaptiveOffset * \Imagick::getQuantum()); $imagick->adaptiveThresholdImage($width, $height, $adaptiveOffsetQuantum); header("Content-Type: image/jpeg"); echo $imagick->getImageBlob(); }