In this post, I will show to you how to make a grayscale image from the original image in laravel. Sometimes, we may require making a grayscale image when end user upload a image. The grayscale image looks better in the event that you have a decent format site. In the article, we will figure out how to make a grayscale picture utilizing intervention package in laravel. Intercession package give a lot of things to do with an image like resize, Grayscale, write on image etc. Intervention package is also perfect to generate a grayscale image.

So, let’s do work with the following steps to generate a grayscale image and save it to your server.

Step 1: Laravel 5 Installation

Here we are going to install and configure basic requirements for Laravel application

Step 2: Install Intervention Image Package

In this step, we will download and install intervention/image package for an image processing using composer.json requirement. This package used to generate a grayscale image from original chosen image. Add the bellow line in composer.json page on require section

and run the composer update command to finish the above step.  After extracting above package we need to add providers and aliases names classes in config/app.php
Step 3: Add Controller for image process

For creating a grayscale image so first, we need to define a controller to handle user request and image process. So create  ImageGrayController.php using command prompt.

After creating controller goto app/Http/Controllers folder also open it and add the below methods for grayscale image process.
Step 5: Define Route

Here we need to define a route for call a view image upload blade template page.

Step 6: Blade Template page creation

Goto the resource/view folder then create imageGrayscale.blade.php page for image upload and show the grayscale image in an HTML page.

 

Leave a Reply

Your email address will not be published. Required fields are marked *