Sets the image compression quality.

function setImageCompressionQuality($image_path, $quality)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->setImageCompressionQuality($quality);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}