php - 如何使用 PHP 从 JPEG 中获取 'title' 和 'tags' exif 数据

标签 php metadata exif

我有大量摄影师为我标记的 JPEG。这是一个例子:

enter image description here

如何使用 PHP 读取“标题”和“标签”数据?我曾尝试使用 exif_read_data 但它不会返回所有信息,这就是它返回的内容:

Array
(
    [FileName] => php57F4.tmp
    [FileDateTime] => 1517222165
    [FileSize] => 10092294
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
    [COMPUTED] => Array
        (
            [html] => width="6085" height="3513"
            [Height] => 3513
            [Width] => 6085
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/1.0
            [FocusDistance] => 0.25m
            [Copyright] => 7831 262511, Copyright Retained by SG Phot
            [Copyright.Photographer] => 7831 262511
            [Copyright.Editor] => Copyright Retained by SG Phot
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [ImageDescription] => Ashwell- Countryside Properties
    [Make] => 
    [Model] => Hasselblad
    [Orientation] => 1
    [XResolution] => 1478517857/892159025
    [YResolution] => 25392/300
    [ResolutionUnit] => 2
    [Software] => 
    [DateTime] => (Macintosh)
    [Artist] => 22 17:40:16
    [Copyright] => 7831 262511
    [Exif_IFD_Pointer] => 12204
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 868
            [JPEGInterchangeFormatLength] => 11154
        )

    [ExposureTime] => 7/766
    [FNumber] => 0/3
    [ExposureProgram] => 1
    [ISOSpeedRatings] => 100
    [ExifVersion] => 0230
    [DateTimeOriginal] => 2018:01:16 11:20:35
    [DateTimeDigitized] => 
    [ShutterSpeedValue] => 824194609/825375280
    [ApertureValue] => 3552570/-1584963
    [ExposureBiasValue] => 1000000/8495855
    [MaxApertureValue] => 1000000/0
    [SubjectDistance] => 1/4
    [MeteringMode] => 255
    [Flash] => 0
    [FocalLength] => 1/1119
    [ColorSpace] => 65535
    [FocalPlaneXResolution] => 1000/28
    [FocalPlaneYResolution] => 1/188679
    [FocalPlaneResolutionUnit] => 3
    [FocalLengthIn35mmFilm] => 22
    [ImageUniqueID] => d
    [UndefinedTag:0xA433] => 7200000CD7
    [UndefinedTag:0xA434] => Hasselb
)

最佳答案

多亏了Syscall 的建议,才得以排序向我推荐以下答案:

https://stackoverflow.com/a/30178223/9135269

我稍微修改了一下,这是我完成的解决方案:

function get_iptc_data( $image_path ) {
    $return = array('title' => '', 'subject' => '', 'tags' => '');
    $size = getimagesize ( $image_path, $info);

    if(is_array($info)) {
        $iptc = iptcparse($info["APP13"]);
        // var_dump($iptc); // this will show all the data retrieved but I'm only concerned with a few 
        $return['title'] = $iptc['2#005'][0];
        $return['subject'] = $iptc['2#120'][0];
        $return['tags'] = $iptc['2#025'];
    }
    return $return;
}

关于php - 如何使用 PHP 从 JPEG 中获取 'title' 和 'tags' exif 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48499458/

相关文章:

php - 如何通过其短代码在 Wordpress 帖子/页面上添加小部件?

python - 为什么拥有一个未绑定(bind)到 SQLAlchemy 引擎的元数据对象很有用?

database - 数据库中的元数据和模式有什么区别?

excel - 这是 Excel 处理 Office Open XML 元数据中的错误吗?

javascript - 有javascript机制修改Image的EXIF元数据信息吗?

php - 我的数据库中有超过 100 万条记录。如何更快地分页......?

php - Auth::check() 在我的 Laravel 项目中似乎无法正常工作

php - 显示 Wordpress 站点标题

c# - 如何在不将图像文件加载到内存的情况下更改图像文件旋转状态

Python EXIF 无法找到拍摄日期信息,但在通过 Windows 属性查看器时存在