Image Manager
Configure Intervention Image
2.6M Downloads / Month
Open Source MIT License
2.6M Downloads / Month
Open Source MIT License
The image manager is the starting point for all operations. With this class you determine the driver to use and call the methods needed for instantiation.
public ImageManager::__construct(string|DriverInterface $driver): ImageManager
The image manager instantiation configures the entire setup and specifies the driver. The possible values for the driver are either an instance or a class name of driver.
Intervention Image is currently shipped with two different drivers. Depending on your PHP installation, you can choose between GD or Imagick.
Intervention\Image\Drivers\Gd\Driver
Intervention\Image\Drivers\Imagick\Driver
Name | Type | Description |
---|---|---|
driver | string or DriverInterface | Image Manager driver instance or driver class name |
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Imagick\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(new Driver());
// alternatively create new manager instance by class name
$manager = new ImageManager(Driver::class);
public static ImageManager::withDriver(string|DriverInterface $driver): ImageManager
The static helper method acts the same way as the constructor and takes either a class name or an instance of the driver.
Name | Type | Description |
---|---|---|
driver | string or DriverInterface | Image Manager driver instance or driver class name |
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Imagick\Driver;
// create new manager instance with desired driver
$manager = ImageManager::withDriver(new Driver());
// or create new manager by class name
$manager = ImageManager::withDriver(Driver::class);
public static ImageManager::gd(): ImageManager
This static helper methods for GD driver creates a new image manager instance directly without arguments.
use Intervention\Image\ImageManager;
// create new image manager with gd driver
$manager = ImageManager::gd();
public static ImageManager::imagick(): ImageManager
This static helper methods takes no arguments and creates a new image manager instance with Imagick driver directly.
use Intervention\Image\ImageManager;
// create new image manager with gd driver
$manager = ImageManager::imagick();
public ImageManager::driver(): DriverInterface
As already described, the Image Manger is created with a driver instance as a dependency. This function ensures that it can be accessed at a later point in time.
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
// create image manager with driver
$manager = new ImageManager(new Driver());
// access driver from image manager
$driver = $manager->driver();
Read more about the different methods of the image manager in the instantiation section
Edit