如何将 BitmapMetadata 键转换为相应的 XMP 名称?
我正在编写一个开源库来提取图像元数据并将其存储为 XML sidecar 中序列化的 XMP(理想情况下与 Adobe 应用程序序列化其元数据的方式相同)。
我的问题是 BitmapMetadata 似乎具有我需要的所有值,但键已损坏。其中许多只是整数,而不是相应的 XMP 命名空间 XML 样式名称。 Microsoft 声称他们正在使用 XMP 来存储 读取/写入媒体中许多不同格式的元数据,但我没有看到任何方法可以从这些元数据中重建一些标准 XMP 名称。
例如,Name="/{ushort=272}"
、Format="ifd"
是我所拥有的,但我需要的是
其中 xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
。为此,我可以使用 ExifUtils 库 中的 ExifTags 来映射一些键,因为我知道它是什么。但我不确定其他许多人的情况。
我的问题:
任何熟悉 BitmapMetadata 的人都知道我是否陷入了死胡同吗?
Microsoft 是否有编码的标准化映射?我尚未在 Adobe 官方 XMP 规范 中找到该规范。
更新:该库的开源代码现已在 Google Code 上以 XmpUtils 库的形式提供。它支持读取/写入 XMP 元数据作为标准的基于 RDF 的 XML。
I am writing an open-source library to extract image metadata and store as XMP serialized in an XML sidecar (ideally identically to how Adobe's apps serialize their metadata).
My problem is it appears that BitmapMetadata has all of the values that I need, but the keys are mangled. Many of them are just integers, rather than their corresponding XMP namespaced XML-style names. Microsoft claims they are using XMP to store reads/writes many different formats of metadata within media, but I do not see any way to reconstruct some of the standard XMP names from these.
For example, Name="/{ushort=272}"
, Format="ifd"
is what I have but I need is <tiff:Model>
where xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
. For this, I can use the ExifTags from my ExifUtils library to map some of the keys because I know what it is. I'm not sure about many of the others though.
My question:
Anyone familiar enough with BitmapMetadata to know if I'm headed down a dead-end?
Is there a standardized mapping that Microsoft is encoding to? I haven't found one yet in Adobe's official XMP specs.
Update: the open source code for this library is now available at Google Code as XmpUtils library. It supports reading/writing XMP metadata as the standard RDF-based XML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我似乎偶然发现了 XMP 第 3 部分中的 第 18 页上的键映射规格。看起来 BitmapMetadata 只是公开了 JPEG 编码的 XMP 数据部分:
不确定最终列表来自哪里,因为这似乎不完整。
更新:
我刚刚偶然发现一组 MSDN 页面(“照片元数据策略”),其中链接到其支持的每个属性的相当全面的 Microsoft 元数据查询语言路径列表(左侧)。这是一种绝对可怕的格式,每页一个路径,但它似乎包含了我需要的大量数据。不幸的是,JPEG 和 TIFF 似乎有不同的路径...
更新:
此外,此页面很关键,因为它定义了这种类似于 XPath 的语法的疯狂之处:元数据查询语言概述
I seem to have stumbled upon the key mapping on page 18 in Part 3 of the XMP spec. It looks like
BitmapMetadata
is simply exposing the JPEG encoded XMP data sections:Not sure where the definitive list comes from as this seems incomplete.
Update:
I just stumbled upon an MSDN set of pages ("Photo Metadata Policy") which links to a fairly comprehensive list of Microsoft Metadata Query Language paths (on left) for each property they support. It is a absolutely horrible format with one path per page but it seems to be a lot of the data I need. Unfortunately it looks like there are different paths for JPEG and TIFF...
Update:
Also this page is key, as it defines the craziness which is this XPath-like syntax: Metadata Query Language Overview
事实证明,BitmapMetadata 使用的 Windows 成像组件 (WIC) 读取/写入许多不同的内容元数据块类型包括 TIFF、EXIF、IPTC、和 XMP。这解释了为什么不幸的是它们的对象模型与 XMP 序列化模型不太对应;它是高度概括的。
我正在寻找的键映射取决于正在解码的部分,即使在 XMP 的情况下,它也不完全是一个干净的转换。其他答案中的 MSDN 链接提供了元数据查询语言的详细描述,该语言是 WIC 用于引用媒体中的元数据部分的类似 XPath 的语法。这对于将每个路径段解析为一个键非常有用,然后可以使用该键来确定相应的 XMP 命名空间和属性名称。
正如我在问题中提到的,我现在构建了这个库,它可以正确转换 TIFF、EXIF 和 XMP 块中很大一部分元数据属性。
请参阅 XmpUtils 库源代码,了解我最终如何以标准化方式提取这些数据的详细信息方式。
As it turns out, the Windows Imaging Component (WIC) used by BitmapMetadata reads/writes many different types of metadata blocks including TIFF, EXIF, IPTC, and XMP. This explains why unfortunately their object model does not correspond very closely with the XMP serialization model; it is highly generalized.
The key mapping which I was looking for depends on which section is being decoded, and even in the case of XMP, it isn't exactly a clean conversion. The MSDN links in the other answer give detailed descriptions of Metadata Query Language which is the XPath-like syntax that WIC uses to reference metadata sections within media. This is useful for parsing each path segment into a key which then may be used to determine the corresponding XMP namespace and property name.
As I mentioned in the question, I've now built this library which correctly converts a very high percentage of the metadata properties from the TIFF, EXIF, and XMP blocks.
See the XmpUtils library source code to see the details of how I ended up extracting this data in a standardized manner.