function autoThresholdImage(
    $image_path,
    int $auto_threshold_method
) {
    $imagick = new \Imagick(realpath($image_path));
    $imagick->autoThresholdImage($auto_threshold_method);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}