ItSolutionStuff.com

Laravel Add Watermark on Image Example

By Hardik Savani • April 16, 2024
Laravel

In this tutorial, i will share with you how to adding watermark to image in laravel 5.8 application. we will add watermark to images using intervention image composer package in laravel 5. we can add image or text as watermark on image in laravel.

I will give you very simple example to add watermark to image in laravel 5, laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 project. many times we need to add watermark to our website images, so we can identify this all images by our website.

in this example, 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 bellow step to add image watermark in laravel 5.

Install intervention/image Package

We need to install intervention/image composer package for adding watermark to image, so you can install using following command:

composer require intervention/image

After that you need to set providers and alias.

config/app.php

.....

'providers' => [

....

Intervention\Image\ImageServiceProvider::class

]

'aliases' => [

....

'Image' => Intervention\Image\Facades\Image::class

]

.....

Add Watermark to image

Here, i will create simple route and add watermark to image. so you need to add two images on your public "images" folder for testing.

make sure you have main.png and logo.png image on your images folder for demo.So let's see bellow example.

Route::get('addWatermark', function()

{

$img = Image::make(public_path('images/main.png'));

/* insert watermark at bottom-right corner with 10px offset */

$img->insert(public_path('images/logo.png'), 'bottom-right', 10, 10);

$img->save(public_path('images/main-new.png'));

dd('saved image successfully.');

});

I hope it van help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Show Data in Modal using Ajax in Laravel?

Read Now →

How to Use and Install Font Awesome Icons in Laravel?

Read Now →

Laravel 10 Image Validation Rule Example

Read Now →

Laravel 10 Crop Image Before Upload Example

Read Now →

Laravel 10 CKeditor Image Upload Example

Read Now →

Laravel 10 CRUD with Image Upload Tutorial

Read Now →

Laravel Profile Image Upload Tutorial with Example

Read Now →

Laravel React JS Image Upload Example

Read Now →

Laravel Webcam Capture Image and Save from Camera Example

Read Now →

Laravel Convert PDF to Image Example

Read Now →

Laravel Livewire Image Upload Example

Read Now →

Laravel Join with Subquery in Query Builder Example

Read Now →

How to Add Text on Image in Laravel?

Read Now →