clock  Mon - Sun 8.00 AM - 8.00 PM
play store

How to add a Text Watermark to an Image in Laravel

writter  Sumit Dey Sarkar
Date  30 Mar 2023
Language  Laravel
How to add a Text Watermark to an Image in Laravel

How to add a Text Watermark to an Image in Laravel

In this tutorial we will learn how to add a text watermark to an image in Laravel.

The technique of overlaying written information over an image, known as image watermarking, may include the display of copyright or other relevant information.

How to add a Text Watermark to an Image in laravel

How to add a Text Watermark to an Image in Laravel

This is also used to confirm the legitimacy of the content(Digital signature).

We will explain how to add a text overlay watermark to an image in the Laravel application. We will use the PHP image intervention package to apply the watermarking text to the image.

A powerful open-source package called Intervention Image is used specifically for image editing in PHP-based apps.

It includes with two sublime processing librariesImagick even more GD library.



Step 1 - Install Intervention Image package

Step 2 - Create a route to handle the image processing

Step 3 - Create a controller

Step 4 - In the controller's addWatermark method, use the make method to open the image and add the text watermark

Step 4 - Create a view to display the watermarked image


Here are the steps:


Step 1 - Install Intervention Image package:

composer require intervention/image


Step 2 - Create a route to handle the image processing:

Route::get('/image/watermark', 'ImageController@addWatermark');


Step 3 - Create a controller:

php artisan make:controller ImageController


Step 4 - In the controller's addWatermark method, use the make method to open the image and add the text watermark:

use Intervention\Image\Facades\Image;

public function addWatermark()
    $image = Image::make('path/to/image.jpg');
    $image->text('Your Watermark Text', $image->getWidth() / 2, $image->getHeight() / 2, function ($font) {
    return $image->response('jpg');

In the above code, we used the text method to add the watermark text to the image. Here we declaire the font, size, color, alignment, and vertical alignment of the text according to requirement.


Step 5 - Finally, create a view to display the watermarked image:

<img src="/image/watermark" alt="Watermarked Image">

That's it! Now, when you visit the route, the controller will add the text watermark to the image and return the watermarked image.


Optionally, we can also add more options to the make method to control the image's quality, format, and other properties:

$image = Image::make('path/to/image.jpg')
            ->encode('jpg', 75) // set image format and quality
            ->resize(800, 600) // resize the image to fit the dimensions
            ->insert('path/to/watermark.png', 'bottom-right', 10, 10); // add an image watermark

in the above we used the encode method to set the output image format and quality, the resize method to resize the image to fit the specified dimensions, and the insert method to add an image watermark.


Note: The insert method accepts the path to the watermark image, the position where the watermark should be inserted the top-left, top-right, bottom-left, bottom-right, center, or any combination of these and the offset values for the X and Y axes.



Don't forget to import the Image class at the top of your controller:

use Intervention\Image\Facades\Image;



How to add a Text Watermark to an Image in laravel

Comments 0

Leave a comment

Coursera, Codeacademy, Udacity, W3Schools, Udemy, Alison, TheNewBoston, edX, P.S.Codewars,Freecodecamp, Managing technical debt blog, Scrimba, Codepen, Codepen/challenges, The Odin Project, htmlreference.​io, cssreference.​io, Frontend Mentor, Dev Challenges, MDN, Code Mentor, Coding Dojo, CSS Battle, Codier, Ace Frontend, Can I Use, CSS Tricks, 30 Seconds of Code,tutorialspoint, Neumorphism, Shaddows Brumm, Fancy Border Radius, Glow Generator, Clothoid Corners, Glassmorphism, Clipy, CSS Filters, Base64 Image, Quantity Queries, Animations, Cubic-Bezier, Keyframes, Wait Animate, Transition.Style, graphic design, web design, website design, website builder, web developer, web designer, webdesign, ecommerce website, web design company, website creator, website designer, responsive web design, web development company, best website design, web design software, web page design, build a website, web developer salary, design website, web design courses, how to design a website, web design inspiration, website layout, web designer salary, web application development, ecommerce website design, web agency, software development company, web design tutorial, web programming, design company, website design templates, what is web designing, web developer jobs, website developer, web design agency, freelance web developer, web design services, freelance web designer, graphic design websites, web solutions, ecommerce website development, free website design, web development courses, webdev, web developers, web development tools, website design services, developpeur web, web design london, website design ideas, web designing and programming, design a website, web design and development, web dev, web development services, homepage design, best designed websites, cheap website design, learn web design, web design templates, web design tools, web design jobs, website design inspiration, web design india, flash website, website developers, designer websites, website services, website design cost, good website design, site design, simple website design, cool website designs, modern website design, graphic designer websites, webcode, best web design software, website making, free web design software, mobile website design, learn web development, front end web developer, how to become a web developer, web developer portfolio, web development company in india, python web development, web development tutorial, website company, website design and development, web company, webdesigning, professional website design, affordable web design, best web design company, creative web design, top website designs, website design pricing, web developer tools, how to develop a website