Intervention Image is an open source PHP library for image handling and manipulation.Intervention image provides image cropping, editing, composing in easier and faster way in Laravel file. In this method coding lines are reduced.It is a library of manipulation of image where you can crop, upload, edit a image.
If you want to create watermark on image or want to write something on image else want to format small and large images, these types of task can be done by intervention in more expressive way. There are many tasks which are performed by intervention easily are:
Let us take an example of editing of an image which will cover most of the functions.
// open an image file
$img = Image::make('public/foo.jpg');
// now you are able to resize the instance
$img->resize(320, 240);
// and insert a watermark for example
$img->insert('public/watermark.png');
// finally we save the image as a new file
$img->save('public/bar.jpg');
Below are the name of the few functions used in editing image in Laravel via intervention Image :
These are the different commands used in editing of an image and intervention makes it more easier and reduce the time.
If you want to create an image then firstly you have to call canvas method. By passing height, width of the image as arguments. The colorization can be done in this method if you want to give the background color of the image then it is also possible to pass it as an argument.
Background color of the image is optional.
Usage:
$img = Image::canvas(800, 600, '#ccc');
Invention of laravel 5 makes it easier to read an image. Now you do not have to do any complicated or annoying work to read an image. For this you have to call the make function and provide the path of the image where the image is stored.
Usage:
$img = Image::make('foo/bar/baz.jpg');
This post is submitted by one of our members. You may submit a new post here.
Laravel interview Questions © 2019 - Designed by PSD to HTML