Advanced
Advanced Image Modification
5.5M Downloads / Month
Open Source MIT License
5.5M Downloads / Month
Open Source MIT License
Advanced Intervention Image techniques: access native image data directly and combine with custom modifier classes for complex transformations.
If the supplied options are not sufficient, you can create your own solutions using your own custom extensions. Furthermore, you can access the native image object, so that all functions used by the actual image processing libraries (such as GD or Imagick) can be used — even those not covered by Intervention Image.
Depending on the driver, each image object is mapped internally by either an
instance of a GDImage::class or an Imagick::class object. The parent image object of
Intervention Image provides access to this base object.
The following example uses the native Imagick function oilPaintImage() which is not included in this library.
use Intervention\Image\ImageManager; use Intervention\Image\Drivers\Imagick\Driver; // read test image from a file $image = ImageManager::usingDriver(Driver::class)->decode('test.png'); // access Imagick instance directly $imagick = $image->core()->native(); // use Imagick method $imagick->oilPaintImage(4.5);
Combined with custom extensions, Intervention Image can be extended with your own modifier combinations for endless possibilities.
The Intervention\Image\ModifierStack class allows you to group existing modifiers together and process them in a single call.
This can be helpful when you need to group individual calls into reusable units without having to create a custom modifier class for that purpose.
use Intervention\Image\Drivers\Gd\Driver; use Intervention\Image\ImageManager; use Intervention\Image\ModifierStack; use Intervention\Image\Modifiers\BrightnessModifier; use Intervention\Image\Modifiers\ContrastModifier; use Intervention\Image\Modifiers\GrayscaleModifier; $image = ImageManager::usingDriver(Driver::class) ->decodePath('example.jpg'); // black and white high contrast stack $stack = new ModifierStack([ new GrayscaleModifier(), new BrightnessModifier(20), new ContrastModifier(12), ]); $image->modify($stack);