How To Resize An Image To Thumbnail In Laravel 7

How To Resize An Image To Thumbnail In Laravel 7

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

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 7, 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 7 Image Upload Tutorial Example
Laravel 7 Ajax Image Upload Example Tutorial
Laravel 7 Multiple Image Upload Example Tutorial

Please follow and like us: