Adjusts the levels of a particular image channel by scaling the minimum and maximum values to the full quantum range.
function autoLevelImage($image_path)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->autoLevelImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}