Friday, June 10, 2016

Resize image in Laravel 5

Resize image in Laravel 5:

For resizing image in laravel:

Firstly we have to install a package. For this open your composer.json and write this code in require.

"intervention/image": "dev-master"

then run composer update

In config/app.php write this code in aliases

'Image'     => Intervention\Image\Facades\Image::class,

and this in providers

Intervention\Image\ImageServiceProvider::class,

Now go to your controller & use this.

use Intervention\Image\Facades\Image;

 Now go to your method and write this code

$dirName = 'path/of/image';
$img = Image::make($dirName . "/background.jpg")->resize(720, 1280);
$img->save($dirName . "/background.jpg");


Thanks

No comments:

Post a Comment