我有一大堆JPEG,摄影师已为我标记了这些内容。这是一个例子:
如何用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
)
答案 0 :(得分:2)
由于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;
}