gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 00:32:51 24 4
gpt4 key购买 nike

我有大量摄影师为我标记的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com