What is the function to load an image in PHP and how can you specify the position for the inserted image?
To load an image in PHP, you can use the `imagecreatefromjpeg()`, `imagecreatefrompng()`, or `imagecreatefromgif()` functions depending on the image type. To specify the position for the inserted image, you can use the `imagecopy()` or `imagecopyresampled()` function to copy a portion of an image to another image at a specified position.
// Load the main image
$main_image = imagecreatefromjpeg('main_image.jpg');
// Load the image to be inserted
$inserted_image = imagecreatefrompng('inserted_image.png');
// Specify the position for the inserted image
$pos_x = 100; // X-coordinate
$pos_y = 50; // Y-coordinate
// Insert the image at the specified position
imagecopy($main_image, $inserted_image, $pos_x, $pos_y, 0, 0, imagesx($inserted_image), imagesy($inserted_image));
// Output the final image
header('Content-Type: image/jpeg');
imagejpeg($main_image, null, 100);
// Free up memory
imagedestroy($main_image);
imagedestroy($inserted_image);