PHP | Imagick filter() Function Last Updated : 25 Jul, 2019 Comments Improve Suggest changes 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 filter() Function 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 PHP | Imagick blurImage() function The Imagick::blurImage() function is an inbuilt function in PHP which is used to add blur filter to the image. This function returns True on success. Syntax: bool Imagick::blurImage( $radius, $sigma, $channel ) Parameters: This function accepts three parameters as mentioned above and described below 1 min read PHP | Imagick chopImage() Function The Imagick::chopImage() function is an inbuilt function in PHP which is used to remove the region of an image and trim it. This function accepts the dimension of image and chops the area and the dimension from where the image is to be trim. Syntax: bool Imagick::chopImage( $width, $height, $x, $y ) 1 min read PHP | Imagick cropImage() Function The Imagick::cropImage() function is an inbuilt function in PHP which is used to extracts the region of the image.Syntax:  int Imagick::cropImage( $width, $height, $x, $y ) Parameters: This function accept four parameters as mention above and describe below.  $width: This parameter is used to spec 2 min read PHP | Imagick drawImage() Function The Imagick::drawImage() function is an inbuilt function in PHP which is used to render the ImagickDraw object on the Imagick object. It is used to draw the image on the Imagick instance. We set an image matrix, parameters and the borders of the drawn image with the help of ImagickDraw methods and t 2 min read Like