I am trying to add Watermark of 800x100px to Images which can have any resolution greater than 800x100, i.e. 801x110, 1200x1000, 1300x200, 1920x1080, 4000x2010, etc.
I want to keep the aspect ratio of Watermark and image to 2:50. i.e., if image has 1000px width, then watarmark over image should occupy 20px(1000/50).
Here is my Function :
in helper.php
use Image;
//calling from Controller
public static function addwatermark ($name) {
$thumbnail = Image::make($name);
$watermarkSource = 'public/img/watermark/watermark.png';
$thumbnail->insert($watermarkSource, 'bottom-left', 0, 0);
$thumbnail->save($name)->destroy();
}
in ImageController.php
$folder = 'public/folder/';
$large = 'myfile.jpeg';
Helper::addwatermark($folder.$large);
source https://stackoverflow.com/questions/68604977/how-to-keep-aspect-ration-of-image-and-watermark-in-laravel-php
Comments
Post a Comment