Laravel 8 Add Watermark on Image

Laravel 8 Add Watermark on Image
Laravel 8 Add Watermark on Image

Hello friends, Today we will show Laravel 8 Add Watermark on Image. In this example i will share with you how to adding watermark to image in laravel 8. In this post we will add watermark to images using intervention image composer package in laravel 8 application.

Here we will show add image or text as watermark on image in laravel. Sometimes we need to add watermark to our website images, so we can identify this all images by our website.

Add Watermark on Images in Laravel 8

Now, In this step i will Add Watermark on Images in Laravel. so let’s following to step by step our code.

Step 1: Create New Laravel Application For Laravel 8 Add Watermark on Image
composer create-project --prefer-dist laravel/laravel Blog

Step 2: Install Image Intervention Package For Add Watermark Text on Image in Laravel

composer require intervention/image

Step 3: Update Config/app.php File


return [

    $providers => [

    $aliases => [
        'Image' => 'Intervention\Image\Facades\Image'


Step 4: Create Controller

php artisan make:controller AddImageController



namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Image;

class AddImageController extends Controller

    public function index()
        return view('welcome');
    public function imageFileUpload(Request $request)
        $this->validate($request, [
            'file' => 'required|image|mimes:jpg,jpeg,png,gif,svg|max:4096',

        $image = $request->file('file');
        $input['file'] = time().'.'.$image->getClientOriginalExtension();

        $imgFile = Image::make($image->getRealPath());

        $imgFile->text('© 2021', 100, 100, function($font) { 

        return back()
        	->with('success','File uploaded successfully ')

Note : Create upload folder in your public directory, path look like public/upload.

Step 5: Create Route


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AddImageController;

Route::get('/file-upload', [AddImageController::class, 'index']);

Route::post('/add-watermark', [AddImageController::class, 'imageFileUpload'])->name('image.watermark');

Step 6: Create Blade File For Upload image

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="" rel="stylesheet">

    <title>Laravel 8 Add Watermark on Image-</title>

    <div class="container">
        <h1>Laravel 8 Add Watermark on Image-</h2>

        <form action="{{route('image.watermark')}}" enctype="multipart/form-data" method="post">
            @if ($message = Session::get('success'))
            <div class="alert alert-success">
                <strong>{{ $message }}</strong>

            <div class="col-md-12 text-center">
                <img src="/uploads/{{ Session::get('fileName') }}" width="100%"/>

            @if (count($errors) > 0)
            <div class="alert alert-danger">
                    @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>

            <div class="mb-3">
                <input type="file" name="file" class="form-control"  id="formFile">

            <div class="d-grid mt-4">
                <button type="submit" name="submit" class="btn btn-primary">
                    Upload File


I hope you understand of Laravel 8 Add Watermark on Image and it can help you…

Read Also :  Laravel Carbon Get Last Day of Month Example