How to add watermark on an image in Laravel 5.8 Step by Step

In this blog post, we will learn, how to add watermark to an image in Laravel 5.8 application, to add watermark to images we will use intervention image composer package in Laravel 5.8. we can add image or text as a watermark on the image in Laravel. For more doc, you can follow

To create copyright on images, make image private we need a watermark image or we can identify this all images by our website. In this post, I will give you a very simple method with the example to add watermark to an image in Laravel 5.8 project.

To make a watermark on an image. we will install intervention/image package and then we will create one simple route to adding image watermark in Laravel app. so let’s follow below step to add image watermark in Laravel 5.8.

Step:1 Install intervention/image Package

At the first step, I install an intervention/image composer package for adding watermark to the image in Laravel 5.8. to install a package using the following command.

composer require intervention/image

After installation, we need to set providers and alias, to do that we need to follow some steps… go to your project and search

config/app.php

‘providers’ => [
Intervention\Image\ImageServiceProvider::class
]
‘aliases’ => [
‘Image’ => Intervention\Image\Facades\Image::class
]

Step:2 Add Watermark to image

Here, I created a controller(you can use a simple route) to add watermark to the image. so you need to add two images on your public “images” folder for testing purpose.

Here I use two images one for the main image and a second image for watermark so I have a main.png and watermark.png image on your images folder for demo.

public function addWatermark(){
$img = Image::make(public_path('images/main.png'));
$img->insert(public_path('watermark.png'),'bottom-right',10, 10);
$img->save();
}

So here we completed tutorials on How to Add Watermark on an Images in Laravel 5.8 step by step.

Software Engineer