Add Watermark on an Images in Laravel 5.8 step by step


In this blog post, we will learn, how to adding 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.

Add Watermark on an Images in Laravel 5.8 step by step

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 flowing command.

composer require intervention/image

After we need to set providers and alias

 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 simple route (you can use as well controller ) 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 logo.png image on your images folder for demo.

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.');
});

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

hope it will help you.


About Author
  • user profile
    Brijpal Sharma

    brijpalsharma99@gmail.com, January 29th, 2018

    Hello, My Name is Brijpal Sharma. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of Codermen. I started this blog to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers...

0 Comment

You must be logged in to post a comment.