PHP Laravel 5 Intervention image upload and resize tutorial

In this post i will tell you how to resize image in laravel application using Intervention library. You can manipulate and handle PHP image by using Intervention library which is open source. You can take help of this library in your application whenever you need thumbnail image or want to resize after uploading images in PHP Laravel.

Benefits of including library intervention/image in your Laravel application, it maintain the image quality that means you can easily resize your images without losing quality.

You will have to simply follow this step to use intervention/image library in your application.

Here in this example, I define a form to submit and on submit i resize images and move them in destination folder with original image too.

It will display both images after successfully moved in target folder.

Step 1: Installation

In this step you will have to configure intervention/image library in your application.

You will have to run below command in your terminal promt.

composer require intervention/image

Now i assume that you have successfully installed by above command.

OK, now i will configure service provider with their aliases name in following path config/app.php .

config/app.php

Add this service provider in provider array :

'Intervention\Image\ImageServiceProvider'

Now add facade to aliases array.

'Image' => 'Intervention\Image\Facades\Image'

Step 2: Add Route

In this step add routes to handle request in following path app/Http/routes.php

app/Http/routes.php

Route::get('intervention-resizeImage',['as'=>'intervention.getresizeimage','uses'=>'FileController@getResizeImage']); Route::post('intervention-resizeImage',['as'=>'intervention.postresizeimage','uses'=>'FileController@postResizeImage']);

Step 3: Add Controller


Originally published at www.laravelfeed.com.

Like what you read? Give LaravelFeed a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.