php – Watermark in image on laravel 5.2


Hi, does anyone know how I could make every image that is uploaded to laravel has a watermark?

The image is sent through a form and through $request->file('img') in the controller I add in the folder and the name of the image in the database, but how to put this watermark in png on the image inside the method in controller ?

mergeimage() from php doesn't work.



Use the intervention/image package, it integrates easily with the Laravel framework following the installation step by step and then integration .

Step by step

$ php composer.phar require intervention/image

After installing the package on your Laravel, go to config/app.php and add this line to the array of providers :


and to make it easier type in the $aliases array

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

and to finish the installation and operation of the package, type in the command line

$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"

How to work with this package:

Route::get('/', function()
    $img = Image::make('foo.jpg')->resize(300, 200);

    return $img->response('jpg');

In your specific case, when saving the image to disk, load it again and call the insert method with the parameter of folder and filename with the extension .png to create the mask in your image and send it to save again.


// open an image file
$img = Image::make('public/foo.jpg');

// now you are able to resize the instance
$img->resize(320, 240);

// and insert a watermark for example

// finally we save the image as a new file

Source: Intervention Image

You can also use directly when uploading the photo:

Scroll to Top