How can PHP be used to add a watermark or copyright text to images in a gallery?

To add a watermark or copyright text to images in a gallery using PHP, you can use the GD library to manipulate images. You would need to load the image, add the watermark or copyright text, and then save the modified image. This can be achieved by overlaying the text on the image using the `imagestring()` or `imagettftext()` function provided by the GD library.

<?php
// Load the image
$image = imagecreatefromjpeg('image.jpg');

// Set the copyright text
$text = "Copyright © Your Company";

// Set the font size and color
$font_size = 20;
$font_color = imagecolorallocate($image, 255, 255, 255);

// Add the text to the image
imagettftext($image, $font_size, 0, 10, 30, $font_color, 'arial.ttf', $text);

// Save the modified image
imagejpeg($image, 'watermarked_image.jpg');

// Free up memory
imagedestroy($image);
?>