What alternative methods or functions can be used to extract metadata from images if the exif_read_data function does not return the desired results?

If the exif_read_data function does not return the desired metadata from an image, an alternative method is to use the getimagesize function combined with the iptcparse function to extract IPTC metadata. This can provide additional information that may not be available through exif data alone. By using these functions in combination, you can retrieve a wider range of metadata from images.

// Get image size and IPTC metadata
$image_info = getimagesize('image.jpg');
$iptc = iptcparse($image_info['APP13']);

// Display IPTC metadata
if(isset($iptc['2#120'])){
    echo 'Caption: ' . $iptc['2#120'][0] . "\n";
}
if(isset($iptc['2#105'])){
    echo 'Title: ' . $iptc['2#105'][0] . "\n";
}
if(isset($iptc['2#110'])){
    echo 'Creator: ' . $iptc['2#110'][0] . "\n";
}