What is the purpose of adding a watermark to images in a Gambio Shop using PHP?

Adding a watermark to images in a Gambio Shop using PHP helps protect your images from being used without permission and also helps in branding your products. This can be achieved by overlaying a transparent image or text on top of the original image.

// Path to the original image
$original_image = 'path/to/original/image.jpg';

// Path to the watermark image
$watermark_image = 'path/to/watermark.png';

// Load the original image
$image = imagecreatefromjpeg($original_image);

// Load the watermark image
$watermark = imagecreatefrompng($watermark_image);

// Set the position for the watermark
$watermark_x = imagesx($image) - imagesx($watermark) - 10; // 10 pixels from the right
$watermark_y = imagesy($image) - imagesy($watermark) - 10; // 10 pixels from the bottom

// Apply the watermark on the original image
imagecopy($image, $watermark, $watermark_x, $watermark_y, 0, 0, imagesx($watermark), imagesy($watermark));

// Output the image with watermark
header('Content-Type: image/jpeg');
imagejpeg($image);

// Free up memory
imagedestroy($image);
imagedestroy($watermark);