PHP 中的 EXIF 标题标签与 exif_read_data()
我在使用 PHP 从 JPG 文件中获取“标题”标签时遇到了一些困难。我想我正在查看错误的 EXIF 组。我使用以下代码:
$exif = exif_read_data( $image['temp_name'], 0, true);
$exif_description = $exif['IFD0']['ImageDescription'];
$exif_title = $exif['WINXP']['Title'];
$exif_iso = $exif['EXIF']['ISOSpeedRatings'];
我查看了 EXIF 标签的一些规范,但我总是想出“XPTitle”作为标题。我没有使用Windows。很难相信它是存储图像标题的唯一可用标签,因为它涉及更改编码。有人可以指点我获得正确的标题吗?
编辑:
我发现它包含在 IPTC 元数据中,可以通过以下方式阅读:
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>';
}
}
}
}
如果有人有改进这个的提示或通过不同的方式解决它,请随时给出一两个提示。 :P
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论