简体   繁体   English

为什么我不能从图像中检索EXIF属性?

[英]Why can't i retrieve EXIF properties from an image?

I Have an image with some properties that i can see in the properties dialog in explorer: 我有一个带有某些属性的图像,可以在资源管理器的属性对话框中看到该图像:

图像属性的屏幕截图

But when i try and retrieve them using the property info as listed on MSDN here 但是当我尝试使用MSDN 此处列出的属性信息检索它们时

var propItem = image.GetPropertyItem(0x010F); // PropertyTagEquipMake = 0x010F
var equipmentMake = Encoding.ASCII.GetString(propItem.Value);

propItem = image.GetPropertyItem(0x0110); // PropertyTagEquipModel = 0x0110
var equipmentModel = Encoding.ASCII.GetString(propItem.Value);

I usually get both values back, but for some files I get the make back but the search for model returns an ArgumentException Property cannot be found. 通常,我会同时获得两个值,但是对于某些文件,我会获得补偿,但是对于模型的搜索返回了ArgumentException属性。

Iterating through the properties on the image like this: 像这样遍历图像上的属性:

foreach (var prop in image.PropertyItems)
{
    Console.WriteLine("{0}\t:\t{1}\t:\t{2}\t:\t{3}", prop.Id, prop.Len, prop.Type, Encoding.UTF8.GetString(prop.Value));
}

(Based on this article) (基于文章)

Reveals that indeed the model property is missing from my image. 显示出我的图像中确实缺少模型属性。

What gives? 是什么赋予了? Is the metadata stored in some other format that i should be looking for? 元数据是否以我应该寻找的其他格式存储?

It could be that the camera model in this files isn't stored as an exif but as an other tag like a xmp or specific camera tag. 可能是此文件中的相机型号未存储为exif,而是存储为xmp或特定相机标签等其他标签。 You can check this for example on http://regex.info/exif.cgi . 例如,您可以在http://regex.info/exif.cgi上进行检查。

When this is the case, I can recommend the great ExifTool from Phil Harvey ( http://www.sno.phy.queensu.ca/~phil/exiftool/ ). 在这种情况下,我可以向Phil Harvey( http://www.sno.phy.queensu.ca/~phil/exiftool/ )推荐出色的ExifTool。

You might try using the MetadataExtractor library. 您可以尝试使用MetadataExtractor库。 It supports lots of different types of metadata (Exif, IPTC, JFIF, XMP...) and several image and video formats. 它支持许多不同类型的元数据(Exif,IPTC,JFIF,XMP ...)以及几种图像和视频格式。

Available on NuGet. 在NuGet上可用。

If you can share your image, I can help diagnose this issue further if you like. 如果可以共享您的图像,我可以根据需要帮助进一步诊断此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM