Laravel 8 Grayscale Image Conversion Tutorial Example

In this tutorial you will learn about the Laravel 8 Grayscale Image Conversion Tutorial Example and its application with practical example.

In this Laravel 8 Grayscale Image Conversion Tutorial I will show you how to convert colour image to grayscale image in laravel application. In this tutorial you will learn to convert or change colour image to grayscale image in laravel. In this example we will be using PHP image intervention package to convert or change colour image to grayscale image.

Laravel 8 Grayscale Image Conversion Tutorial Example

In this step by step tutorial I will demonstrate you how to convert an colour image to grayscale image in laravel application. Please follow the instruction given below:

  • Step 1: Install Laravel App
  • Step 2: Add Intervention Image Library
  • Step 3: Setting Up Controller
  • Step 4: Register New Routes
  • Step 5: Build Blade View in CI
  • Step 6: Run CI Application

Install Laravel App

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Add Intervention Image Library

In this step, we will install Image intervention Package via the composer dependency manager. Use the following command to install image intervention Package.

After Installing Image intervention package, we need to add service provider and alias in config/app.php file as following.

config/app.php

Create Controller By Artisan Command

Now, lets create a controller named FileUploadController using command given below –

Once the above command executed, it will create a controller file FileUploadController.php in app/Http/Controllers/ directory. Open the FileUploadController.php file and put the following code in it.

app/Http/Controllers/FileUploadController.php

Create Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Create Blade Views

In this step, we will create view/blade file with basic file upload form. Lets create a blade file “profile.blade.php” in “resources/views/” directory and put the following code in it respectively.

resources/views/profile.blade.php

Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

In this tutorial we have learn about the Laravel 8 Grayscale Image Conversion Tutorial Example and its application with practical example. I hope you will like this tutorial.