What functions in PHP can be used to manipulate images and merge them together?

To manipulate images and merge them together in PHP, you can use functions like imagecreatefromjpeg(), imagecopy(), and imagejpeg(). These functions allow you to create image resources from JPEG files, copy one image onto another, and save the merged image as a new JPEG file.

// Load the images
$image1 = imagecreatefromjpeg('image1.jpg');
$image2 = imagecreatefromjpeg('image2.jpg');

// Merge the images
imagecopy($image1, $image2, 0, 0, 0, 0, imagesx($image2), imagesy($image2));

// Save the merged image
imagejpeg($image1, 'merged_image.jpg');

// Free up memory
imagedestroy($image1);
imagedestroy($image2);