'EXIF Title tag in PHP with with exif_read_data()
I have some struggles to get the "Title" tag from a JPG file with PHP. I guess I'm looking through the wrong EXIF group. I'm using following code:
$exif = exif_read_data( $image['temp_name'], 0, true);
$exif_description = $exif['IFD0']['ImageDescription'];
$exif_title = $exif['WINXP']['Title'];
$exif_iso = $exif['EXIF']['ISOSpeedRatings'];
I looked through some specs of EXIF tags, but I always come up with "XPTitle" as the title. I'm not using Windows. It's hard to believe that it's the only available tag to store the title of the image as it involves changing the encoding. Can someone point me to get the proper title?
Edit:
I figured out it is included in the IPTC metadata which can be read in the following way:
output_iptc_data($bild);
function output_iptc_data( $image_path ) {
$size = getimagesize ( $image_path, $info);
if(is_array($info)) {
$iptc = iptcparse($info["APP13"]);
foreach (array_keys($iptc) as $s) {
$c = count ($iptc[$s]);
for ($i=0; $i <$c; $i++)
{
echo $s.' = '.$iptc[$s][$i].'<br>';
}
}
}
}
If someone has a hint to improve this or figure it out through a different way, please feel free to give a hint or two. :P
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|