PHP | Imagick filter() Function Last Updated : 25 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Imagick::filter() function is an inbuilt function in PHP which is used to apply custom convolution kernel to the image. A kernel, convolution matrix, or mask is a small matrix. It is used for blur, sharpen, embossing, edge detection, and many more. Syntax: bool Imagick::filter( $ImagickKernel, $channel = Imagick::CHANNEL_UNDEFINED ) Parameters: This function accepts two parameters as mentioned above and described below: $ImagickKernel: It is a kernel or a linked series of multiple kernels that are used to be apply on the image. $channel: It is a constant that is used on basis of the modes. It is of integer type and the default value of channel is Imagick::CHANNEL_DEFAULT. Return Value: It returns true when the filter to the image is successfully applied. Below program illustrates the Imagick::filter() function in PHP: Program: php <?php // Declare an imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); // Declare convolution matrix $matrix = [ [-1, 0, -1], [0, 5, 0], [-1, 0, -1], ]; $kernel = \ImagickKernel::fromMatrix($matrix); $strength = 0.5; // Scaling the image on kernel $kernel->scale($strength, \Imagick::NORMALIZE_KERNEL_VALUE); // Use addUnityKernel() function $kernel->addUnityKernel(1 - $strength); // Use filter() function $imagick->filter($kernel); header("Content-Type: image/jpg"); // Display the output image echo $imagick->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagick.filter.php Comment More infoAdvertise with us Next Article PHP | Imagick flattenImages() Function P piyush25pv Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick clear() Function The Imagick::clear() function is an inbuilt function in PHP which is used to clear all resource allocated to an Imagick object. Syntax: bool Imagick::clear( void ) Parameters: This function does not accept any parameter. It just clears off the resources of the Imagick object which is used to call th 2 min read PHP | Imagick clone() Function The Imagick::clone() function is an inbuilt function in PHP which is used to create a copy of Imagick object. This function creates copy of the same instance, that means it will have same properties and any change in it will not reflect to the main object. Syntax: Imagick Imagick::clone( void ) Para 1 min read PHP | Imagick destroy() Function The Imagick::destroy() function is an inbuilt function in PHP which is used to destroy the Imagick object and free all the resources associated with it. You can't access your object content once it is destroyed. Syntax: bool Imagick::destroy( void ) Parameters: This function does not accept any para 1 min read PHP | Imagick addImage() Function The Imagick::addImage() function is an inbuilt function in PHP which is used to adds new image to Imagick object image list. After the operation iterator position is moved at the end of the list. This function adds new image to Imagick object from the current position of the source object. The Imagi 1 min read PHP | Imagick flattenImages() Function The Imagick::flattenImages() function is an inbuilt function in PHP which is used to merges the sequence of images. This is useful for combining Photoshop layers into a single image. Syntax: Imagick Imagick::flattenImages( void ) Parameters: This function does not accept any parameter. Return Value: 1 min read PHP | Imagick __construct() Function The Imagick::__construct() function is an Imagick class constructor which takes the image path or image URL as parameter to instantiate the Imagick object for a specific image or a set of images. Syntax: Imagick::__construct( $files ) Parameters: This function accepts single parameter $files which h 1 min read Like