Reduces the speckle noise in an image while preserving the edges of the original image.
function despeckleImage($image_path)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->despeckleImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}