我正在尝试使用带有 C# 的 metadata-extractor-dotnet 从 JEPG 文件中读取 Microsoft 照片 XMP 人物标签(名称和矩形)。到目前为止,我只能使用某种hacky代码来提取人名。我想知道是否有更简洁的方法。
背景 1:我正在尝试读取这些 XMP 元数据值:https://exiftool.org/TagNames/Microsoft.html -> Microsoft MP 标签 -> RegionPersonDisplayName & RegionRectangle
背景 2:当使用 metadata-extractor-dotnet (xmpDirectory.XmpMeta.Properties
) 迭代 JPEG 中的 XML 值时,我看到以下值:
我的工作和提取人名的hacky代码如下所示:
var array1 = GetXmpArrayOrNull(XmpDirectory?.XmpMeta, "http://ns.microsoft.com/photo/1.2/", "MP:RegionInfo/MPRI:Regions");
if (array1 != null)
{
return array1
.Select((_, i) => XmpDirectory?.XmpMeta?.GetProperty("http://ns.microsoft.com/photo/1.2/", $"MP:RegionInfo/MPRI:Regions[{i + 1}]/MPReg:PersonDisplayName")?.Value)
.Where(s => !string.IsNullOrEmpty(s))
.ToList()
}
在我的代码中,array1
数组似乎没有保存任何可用数据。所以我只用它的存在作为一个指标,表明在不同的查询下有更多的数据可用。
知道如何直接获取一个“东西”数组,我可以直接访问 PersonDisplayName 和 Rectangle 吗?