Reading & creating images
2.1M Downloads / Month
Open Source MIT License
public ImageManager::make(mixed $source): ImageInterface
With Intervention Image you are able to read images from severeal different sources. The starting point is an instance of the
Intervention\Image\ImageManager class. This class provides a universal method
make() to read different types of image sources.
This method not only supports filepaths as an argument. The following argument formats are accepted.
If the given argument can not be decoded by the library an exception of type
Intervention\Image\Exceptions\DecoderException is thrown.
use Intervention\Image\ImageManager; // create new manager instance with desired driver $manager = new ImageManager('imagick'); // read image from filesystem $image = $manager->make('images/example.jpg'); // read image from binary data $image = $manager->make(file_get_contents('images/example.jpg'));
public ImageManager::create(int $width, int $height, mixed $background = 'transparent'): ImageInterface
Reading existing image sources is one thing, but what if you want to create your own images? Intervention Images can help you with that. You start with an instance of the
Intervention\Image\ImageManager class and call the
create() method with the desired image size as arguments. See the following example:
By default the image is created with a transparent background. If you want to define a background color instead use an optional third parameter.
|background (optional)||mixed||Background color|
use Intervention\Image\ImageManager; // create new manager instance with desired driver $manager = new ImageManager('gd'); // create new image 640x480 $image = $manager->create(640, 480); // create new image 512x512 with grey background $image = $manager->create(512, 512, 'ccc');