-2

I want to add a watermark to my uploaded image using intervention image library in laravel.I have installed it through command composer require intervention/image , added Intervention\Image\ImageServiceProvider::class in providers array and 'Image' => Intervention\Image\Facades\Image::class in aliases array.

This is my code sample:

if($request->file1)
    {
        $this->validate($request, [
            'file1' => 'required|image|mimes:jpeg,png,jpg,gif,svg',
        ]);
        $imageName = time().'-'.rand(11111, 99999).'.'.$request->file1->getClientOriginalExtension();
        $imageName = $imageName->insert('https://www.exabytes.my/wp-content/uploads/400x150-exabytes-logo.png','center');
        $request->file1->move('theme/img/properties', $imageName);
    }
Sand Of Vega
  • 2,297
  • 16
  • 29
Irfan Ullah
  • 65
  • 1
  • 9

1 Answers1

1

You have to actually use the Image class/facade:

$imageName = time().'-'.rand(11111, 99999).'.'.$request->file1->getClientOriginalExtension();
$file = $request->file1->move('theme/img/properties', $imageName);
$source = 'https://www.exabytes.my/wp-content/uploads/400x150-exabytes-logo.png';
Image::make($file->getPath())->insert($source, 'center');
Jonas Staudenmeir
  • 24,815
  • 6
  • 63
  • 109