HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue
Category
Example

Add noise image

← adaptiveThresholdImage   addNoiseImageWithAttenuate →
Adds random noise to the image.
NOISE_UNIFORM = 1;
NOISE_GAUSSIAN = 2;
NOISE_MULTIPLICATIVEGAUSSIAN = 3;
NOISE_IMPULSE = 4;
NOISE_LAPLACIAN = 5;
NOISE_POISSON = 6;
NOISE_RANDOM = 7;

// Example 1
function addNoiseImage($noiseType, $image_path, $channel)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->addNoiseImage($noiseType, $channel);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}
// Example 2 - WithAttenuate
function addNoiseImageWithAttenuate($noiseType, $attenuate, $image_path, $channel)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->addNoiseImageWithAttenuate($noiseType, $attenuate, $channel);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}