HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

ImagickKernel::addKernel

  addUnityKernel →
Attach another kernel to this kernel to allow them to both be applied in a single morphology or filter function. Returns the new combined kernel.

Example

function addKernel($image_path)
{
    $matrix1 = [
        [-1, -1, -1],
        [ 0,  0,  0],
        [ 1,  1,  1],
    ];

    $matrix2 = [
        [-1,  0,  1],
        [-1,  0,  1],
        [-1,  0,  1],
    ];

    $kernel1 = ImagickKernel::fromMatrix($matrix1);
    $kernel2 = ImagickKernel::fromMatrix($matrix2);
    $kernel1->addKernel($kernel2);

    $imagick = new \Imagick(realpath($image_path));
    $imagick->convolveImage($kernel1);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();

}