Add Watermark on Images in Laravel

Add Watermark on Images in Laravel

In this post we will give you information about Add Watermark on Images in Laravel. Hear we will give you detail about Add Watermark on Images in LaravelAnd how to use it also give you demo for it if it is necessary.

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.8 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' => [

....

InterventionImageImageServiceProvider::class

]

'aliases' => [

....

'Image' => InterventionImageFacadesImage::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.

Also see:Laravel 5.8 Datatables Tutorial

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…

Hope this code and post will helped you for implement Add Watermark on Images in Laravel. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

9  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US