简体   繁体   中英

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

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.

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. You can check this for example on 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/ ).

You might try using the MetadataExtractor library. It supports lots of different types of metadata (Exif, IPTC, JFIF, XMP...) and several image and video formats.

Available on NuGet.

If you can share your image, I can help diagnose this issue further if you like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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