Using PHP I am trying to add watermark images, I am using Intervention Image library for the same
I have a requirement to add a watermark a bit right side, infact a bottom-right portion of the image
but my XY cordinates place the watermark outside of the image
Here is my piece of code
$x = ($targetWidth - $resizedWidth) / 2; // Horizontal padding
$y = ($targetHeight - $resizedHeight) / 2; // Vertical padding
$originalImage->resize($resizedWidth, $resizedHeight, function ($constraint) {
$constraint->aspectRatio();
});
// Create a new canvas with the target dimensions and fill it with white color
$newImage = Image::canvas($targetWidth, $targetHeight, '#FF0000');
// Paste the resized image onto the new canvas at the calculated position
$newImage->insert($originalImage, 'top-left', (int)$x, (int)$y);`
Any help ?
While using the X , Y cordinated make sure your keep the position of your watermark at center I saw its 'top-left' right now . that could be the hurdle.
Try
$newImage->insert($originalImage, 'center', (int)$x, (int)$y);