How can XMP image metadata be edited in a JPG file using PHP?

To edit XMP image metadata in a JPG file using PHP, you can use the `exif_read_data()` and `exif_imagetype()` functions to read the existing metadata, modify it as needed, and then write it back to the file using `exif_write_data()`. Make sure to handle any errors or exceptions that may occur during the process.

$filename = 'example.jpg';

// Read existing metadata
$exif = exif_read_data($filename, 'ANY_TAG', true);

// Modify the metadata as needed
$exif['XMP']['SomeXMPField'] = 'New Value';

// Write the modified metadata back to the file
if(!exif_write_data($exif, $filename)) {
    echo 'Error writing metadata';
} else {
    echo 'Metadata updated successfully';
}