how to resize an image to thumbnail in laravel 6

how to resize an image to thumbnail in laravel 6

In this tutorial, we are going on how to resize an image to thumbnail in laravel 6. so here we are using the intervention package for resizing images.
The intervention package provides image resize and upload facility. so we can easily create laravel upload image resize to thumbnail. let’s follow the below steps to image resize using intervention image resize in laravel 6.

Overview

Step 1: Install Laravel
Step 2: Setting Database Configuration
Step 3: Create Table using migration
Step 4: Install Package
Step 5: Add providers and aliases
Step 6: Create Route
Step 7: Create a Model and Controller
Step 8: Create Blade Files
Step 9: Run The Application

Step 1: Install Laravel
We are going to install laravel 6, so first open the command prompt or terminal and go to go to xampp htdocs folder directory using the command prompt. after then run the below command.

Step 2: Setting Database Configuration

After complete installation of laravel. we have to database configuration. now we will open the .env file and change the database name, username, password in the .env file. See below changes in a .env file.

Step 3: Create Table using migration

Now, We need to create a migration. so we will below command using create the images table migration.

After complete migration. we need below changes in the database/migrations/create_images_table file.

Run the below command. after the changes above file.

Step 4: Install Package
Now, we are going to install the “Intervention” package using the below command.

Step 5: Add providers and aliases
We will add below providers and aliases in the “config/app.php” file.

Step 6: Create Route

Add the following route code in the “routes/web.php” file.

Step 7: Create a Model and Controller

Here below command help to create the controller and model.

Image.php

ImageController.php

Step 8: Create Blade Files

So finally, first we will create the image.blade.php files in “resources/views” directory.

image.blade.php

Step 9: Run The Application

We can start the server and run this application using the below command.

Now we will run our example using the below Url in the browser.

Download

Read Also
Laravel 6 Image Upload Tutorial Example
Laravel 6 Ajax Image Upload Example Tutorial
Laravel 6 Multiple Image Upload Example Tutorial

Please follow and like us: