---
application: "Intervention Image"
version: "Version 2"
status: "eol"
---

# Image Filters

## Bundle image operations in classes



Image Filters in Intervention Image give you the useful possibility to group image transformations commands into a dedicated object. This object defines which command, in which order and with which arguments should be called on an image instance.

Intervention Image provides the basic ```Intervention\Image\Filters\FilterInterface```, which all filters need to implement.

Once you have created your own filters, you can apply them using the [filter()](https://image.intervention.io/v2/api/filter.md) method.

#### Applying the demo filter

```php
// init new image instance
$img = Image::make('foo.jpg');

// apply filter
$img->filter(new DemoFilter(45));
```

Take a look at the example of the DemoFilter ```src/Intervention/Image/Filters/DemoFilter.php``` which combines a greyscale/pixelate effect.

#### DemoFilter Example

```php
namespace Intervention\Image\Filters;

class DemoFilter implements FilterInterface
{
    /**
     * Default size of filter effects
     */
    const DEFAULT_SIZE = 10;

    /**
     * Size of filter effects
     *
     * @var integer
     */
    private $size;

    /**
     * Creates new instance of filter
     *
     * @param integer $size
     */
    public function __construct($size = null)
    {
        $this->size = is_numeric($size) ? intval($size) : self::DEFAULT_SIZE;
    }

    /**
     * Applies filter effects to given image
     *
     * @param  Intervention\Image\Image $image
     * @return Intervention\Image\Image
     */
    public function applyFilter(\Intervention\Image\Image $image)
    {
        $image->pixelate($this->size);
        $image->greyscale();

        return $image;
    }
}
```

---

## Become a Sponsor

### Intervention Image needs your help to keep the project going

Intervention Image is non-commercial, open source licensed and completely free to use. The considerable
effort required to maintain and develop the software is only possible with the financial support
of sponsors. There are two ways in which you can support this project.

- Support via [GitHub Sponsors](https://github.com/sponsors/Intervention)
- Support via [Ko-Fi](https://ko-fi.com/interventionphp)