php - 使用 PHP 读取自定义图像标签元数据

标签 php image metadata

我正在尝试使用 PHP 从在 Windows Live 照片库中编辑的图像中读取图像标签“People”。 默认情况下,此标签不存在,但一旦有人在此图像上被标记,照片库就会将标签“人物”添加到图像元数据中。

Desctiprion - People TAG

我正在尝试读取 people 标签,但 php 没有读取它。

这是我试过的代码:

$exif = exif_read_data($filename, 0, true);
var_dump($exif);

这段代码返回了除此之外的所有标签。

结果: enter image description here

非常感谢你在这方面的帮助。

谢谢

这是一个示例图片,如果你想测试一下: http://www.mediafire.com/download/f2wpdrwsb8lajpj/TWblHuo.zip


我想得到这个“xc”值 在 cmd 中尝试 jhead 解决方案后,这是输出:

<?xml version="1.0" encoding="utf-8"?>


C:\wamp\www\photos>jhead.exe -v C:\Users\joseph.azzam1\Desktop\Highres\sample.jp
g
JFIF SOI marker: Units: 1 (dots per inch)  X-density=96 Y-density=96
Exif header 14466 bytes long
Exif section in Motorola order
(dir has 8 entries)
    ImageDescription = "edgf"
    DateTime = "2015:06:30 15:39:28"
    Unknown Tag 4746 Value = 2
    Unknown Tag 4749 Value = 25
    ExifOffset = 2130
    Exif Dir:(dir has 1 entries)
        Unknown Tag ea1c Value = "?Ω?"
    Windows-XP Title = edgf
    Windows-XP subject = test
    Unknown Tag ea1c Value = "?Ω?"
    Continued directory (dir has 6 entries)
        Compression = 6
        XResolution = 96/1
        YResolution = 96/1
        ResolutionUnit = 2
        ThumbnailOffset = 4304
        ThumbnailLength = 10153
Thumbnail size: 10153 bytes
COM marker comment: CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality
?
Image cotains XMP section, 14753 bytes long
9?http://ns.adobe.com/xap/1.0/?<?xpacket begin='???' id='W5M0MpCehiHzreSzNTczkc9
d'?>?
<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/0
2/22-rdf-syntax-ns#"
><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:xm
p="http://ns.adobe.c
om/xap/1.0/"><xmp:CreatorTool>Microsoft Photo Gallery 16.4.3528.331</xmp:Creator
Tool><xmp:Rating>2</
xmp:Rating></rdf:Description><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da
-ad31-d33d75182f1b"
xmlns:MP="http://ns.microsoft.com/photo/1.2/"><MP:RegionInfo><rdf:Description xm
lns:rdf="http://www.
w3.org/1999/02/22-rdf-syntax-ns#"><MPRI:Regions xmlns:MPRI="http://ns.microsoft.
com/photo/1.2/t/Regi
onInfo#"><rdf:Bag xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:l
i><rdf:Description x
mlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><MPReg:Rectangle xmlns:MP
Reg="http://ns.micro
soft.com/photo/1.2/t/Region#">0.144259, 0.358824, 0.065751, 0.098529</MPReg:Rect
angle></rdf:Descript
ion>?
???????</rdf:li><rdf:li><rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22
-rdf-syntax-ns#"><MP
Reg:Rectangle xmlns:MPReg="http://ns.microsoft.com/photo/1.2/t/Region#">0.211973
, 0.294118, 0.023553
, 0.035294</MPReg:Rectangle></rdf:Description>?
???????</rdf:li><rdf:li><rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22
-rdf-syntax-ns#"><MP
Reg:Rectangle xmlns:MPReg="http://ns.microsoft.com/photo/1.2/t/Region#">0.350343
, 0.423529, 0.056919
, 0.085294</MPReg:Rectangle><MPReg:PersonDisplayName xmlns:MPReg="http://ns.micr
osoft.com/photo/1.2/
t/Region#">xc</MPReg:PersonDisplayName></rdf:Description>?
???????</rdf:li><rdf:li><rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22
-rdf-syntax-ns#"><MP
Reg:Rectangle xmlns:MPReg="http://ns.microsoft.com/photo/1.2/t/Region#">0.352306
, 0.300000, 0.023553
, 0.035294</MPReg:Rectangle></rdf:Description>?
???????</rdf:li><rdf:li><rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22
-rdf-syntax-ns#"><MP
Reg:Rectangle xmlns:MPReg="http://ns.microsoft.com/photo/1.2/t/Region#">0.395486
, 0.304412, 0.047105
, 0.070588</MPReg:Rectangle></rdf:Description>?
???????</rdf:li><rdf:li><rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22
-rdf-syntax-ns#"><MP
Reg:Rectangle xmlns:MPReg="http://ns.microsoft.com/photo/1.2/t/Region#">0.823356
, 0.560294, 0.095191
, 0.142647</MPReg:Rectangle></rdf:Description>?
???????</rdf:li></rdf:Bag>?
?????</MPRI:Regions></rdf:Description>?
???</MP:RegionInfo></rdf:Description><rdf:Description xmlns:MicrosoftPhoto="http
://ns.microsoft.com/
photo/1.0/"><MicrosoftPhoto:Rating>25</MicrosoftPhoto:Rating></rdf:Description><
rdf:Description xmln
s:dc="http://purl.org/dc/elements/1.1/"><dc:title><rdf:Alt xmlns:rdf="http://www
.w3.org/1999/02/22-r
df-syntax-ns#"><rdf:li xml:lang="x-default">edgf</rdf:li></rdf:Alt>?
???</dc:title></rdf:Description><rdf:Description xmlns:dc="http://purl.org/dc/el
ements/1.1/"><dc:des
cription><rdf:Alt xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:l
i xml:lang="x-defaul
t">edgf</rdf:li></rdf:Alt>?
???</dc:description></rdf:Description></rdf:RDF></x:xmpmeta>?


Approximate quality factor for qtable 0: 75 (scale 50.51, var 0.81)
Approximate quality factor for qtable 1: 75 (scale 50.52, var 0.19)
JPEG image is 1019w * 680h, 3 color components, 8 bits per sample
File name    : C:\Users\joseph.azzam1\Desktop\Highres\sample.jpg
File size    : 110626 bytes
File date    : 2015:07:01 13:29:21
Date/Time    : 2015:06:30 15:39:28
Resolution   : 1019 x 680
Comment      : CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality
Comment      : ?


C:\wamp\www\photos>pause
Press any key to continue . . .

使用:

var_dump( system("jhead.exe -v $filename"));

这是 php 输出:

JFIF SOI marker: Units: 1 (dots per inch) X-density=96 Y-density=96 Exif header 14466 bytes long Exif section in Motorola order (dir has 8 entries) ImageDescription = "edgf" DateTime = "2015:06:30 15:39:28" Unknown Tag 4746 Value = 2 Unknown Tag 4749 Value = 25 ExifOffset = 2130 Exif Dir:(dir has 1 entries) Unknown Tag ea1c Value = "?ê?" Windows-XP Title = edgf Windows-XP subject = test Unknown Tag ea1c Value = "?ê?" Continued directory (dir has 6 entries) Compression = 6 XResolution = 96/1 YResolution = 96/1 ResolutionUnit = 2 ThumbnailOffset = 4304 ThumbnailLength = 10153 Thumbnail size: 10153 bytes COM marker comment: CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality ? Image cotains XMP section, 14753 bytes long 9?http://ns.adobe.com/xap/1.0/?? Microsoft Photo Gallery 16.4.3528.33120.144259, 0.358824, 0.065751, 0.098529? ???????0.211973, 0.294118, 0.023553 , 0.035294? ???????0.350343, 0.423529, 0.056919 , 0.085294xc? ???????0.352306, 0.300000, 0.023553 , 0.035294? ???????0.395486, 0.304412, 0.047105 , 0.070588? ???????0.823356, 0.560294, 0.095191 , 0.142647? ???????? ?????? ???25edgf? ???edgf? ???? Approximate quality factor for qtable 0: 75 (scale 50.51, var 0.81) Approximate quality factor for qtable 1: 75 (scale 50.52, var 0.19) JPEG image is 1019w * 680h, 3 color components, 8 bits per sample File name : C:\Users\joseph.azzam1\Desktop\Highres\sample.jpg File size : 110626 bytes File date : 2015:07:01 13:29:21 Date/Time : 2015:06:30 15:39:28 Resolution : 1019 x 680 Comment : CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality Comment : ?

最佳答案

我认为您正在寻找的信息可能是 XML 格式的 PersonDisplayName 如果您使用 jhead -v 像这样查看它:

jhead -v YourImage.jpg

JFIF SOI marker: Units: 1 (dots per inch)  X-density=96 Y-density=96
Jpeg section marker 0xee size 14
Exif header 15200 bytes long
Exif section in Motorola order
(dir has 3 entries)
    DateTime = "2015:07:02 13:48:49"
    ExifOffset = 2130
    Exif Dir:(dir has 1 entries)
        Unknown Tag ea1c Value = "?Í?"
    Unknown Tag ea1c Value = "?Í?"
    Continued directory (dir has 6 entries)
        Compression = 6
        XResolution = 96/1
        YResolution = 96/1
        ResolutionUnit = 2
        ThumbnailOffset = 4304
        ThumbnailLength = 10887
Thumbnail size: 10887 bytes
Jpeg section marker 0xe2 size 3160
Image cotains XMP section, 13513 bytes long
4?http://ns.adobe.com/xap/1.0/?<?xpacket begin='???' id='W5M0MpCehiHzreSzNTczkc9d'?>?
<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:xmp="http://ns.adobe.c
om/xap/1.0/"><xmp:CreatorTool>Microsoft Photo Gallery 16.4.3528.331</xmp:CreatorTool></rdf:Descripti
on><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:MP="http://ns.micros
oft.com/photo/1.2/"><MP:RegionInfo><rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-synt
ax-ns#"><MPRI:Regions xmlns:MPRI="http://ns.microsoft.com/photo/1.2/t/RegionInfo#"><rdf:Bag xmlns:rd
f="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li><rdf:Description xmlns:rdf="http://www.w3.or
g/1999/02/22-rdf-syntax-ns#"><MPReg:Rectangle xmlns:MPReg="http://ns.microsoft.com/photo/1.2/t/Regio
n#">0.640479, 0.324515, 0.186418, 0.246914</MPReg:Rectangle><MPReg:PersonDisplayName xmlns:MPReg="ht
tp://ns.microsoft.com/photo/1.2/t/Region#">xc</MPReg:PersonDisplayName></rdf:Description>?
???????</rdf:li></rdf:Bag>?
?????</MPRI:Regions></rdf:Description>?
???</MP:RegionInfo></rdf:Description></rdf:RDF></x:xmpmeta>?

Approximate quality factor for qtable 0: 98 (scale 3.50, var 4.81)
Approximate quality factor for qtable 1: 98 (scale 3.16, var 0.50)
JPEG image is 751w * 567h, 3 color components, 8 bits per sample
File name    : TWblHuo.jpg
File size    : 253697 bytes
File date    : 2015:07:02 13:48:50
Date/Time    : 2015:07:02 13:48:49
Resolution   : 751 x 567

关于php - 使用 PHP 读取自定义图像标签元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31182572/

相关文章:

postgresql - postgresql 的 jdbc 驱动程序的 "ResultSet.getMetaData.getTableName(col)"总是返回一个空字符串是否正确?

iphone - 如何将自定义元数据标签添加到 iPhone 上的图像?

php - Qcodo vs. CakePHP vs. Zend

javascript - 在文本区域标签中键入命令时触发函数

php - Laravel 显示多对多关系项

python - 在 python PIL 中使用三次插值放大图像

python - 无需下载整个图像即可获取 EXIF 数据 - Python

php - 存储 0、1、空值的最佳数据类型

php - Drupal 8 - 图像样式未在第一页加载时显示

memory - Hadoop Namenode 元数据 - fsimage 和编辑日志