Arian Kulp's Blog
opinion, insight, and occasional code

What's up with EXIF properties in .NET?

Monday, April 16, 2007 10:45 AM

Warning!  This is a long post!  I've been working on a project working with images (the most GDI+ I've ever done so far!) and I'm stymied.  Nothing I do seems to get me access to the title/caption/description for the image.  As I understand it, I should be able to read 0x320, 0x10e, or possible 0x9c9b (using Bitmp.GetPropertyItem().  None of these exist in the properties collection even though they should be set and they show up in the Windows tools.

This is the complete list that I get from enumerating the list (I'm only displaying values from strings (type 2), short (3), and long (4):

>> ID: 10f (Type=2) = Canon
>> ID: 110 (Type=2) = Canon PowerShot S2 IS
>> ID: 112 (Type=3) = 8
>> ID: 11a (Type=5) =
>> ID: 11b (Type=5) =
>> ID: 128 (Type=3) = 2
>> ID: 132 (Type=2) = 2007:02:08 20:57:37
>> ID: 213 (Type=3) = 1
>> ID: 1001 (Type=3) = 2592
>> ID: 1002 (Type=3) = 1944
>> ID: 829a (Type=5) =
>> ID: 829d (Type=5) =
>> ID: 9000 (Type=7) =
>> ID: 9003 (Type=2) = 2007:02:08 20:57:37
>> ID: 9004 (Type=2) = 2007:02:08 20:57:37
>> ID: 9101 (Type=7) =
>> ID: 9102 (Type=5) =
>> ID: 9201 (Type=10) =
>> ID: 9202 (Type=5) =
>> ID: 9204 (Type=10) =
>> ID: 9205 (Type=5) =
>> ID: 9207 (Type=3) = 2
>> ID: 9209 (Type=3) = 9
>> ID: 920a (Type=5) =
>> ID: 927c (Type=7) =
>> ID: 9286 (Type=7) =
>> ID: a000 (Type=7) =
>> ID: a001 (Type=3) = 1
>> ID: a002 (Type=3) = 2592
>> ID: a003 (Type=3) = 1944
>> ID: a20e (Type=5) =
>> ID: a20f (Type=5) =
>> ID: a210 (Type=3) = 2
>> ID: a217 (Type=3) = 2
>> ID: a300 (Type=7) =
>> ID: 9c9b (Type=1) =
>> ID: 9c9c (Type=1) =
>> ID: 9c9d (Type=1) =
>> ID: 9c9e (Type=1) =
>> ID: 9c9f (Type=1) =
>> ID: a401 (Type=3) = 0
>> ID: a402 (Type=3) = 0
>> ID: a403 (Type=3) = 0
>> ID: a404 (Type=5) =
>> ID: a406 (Type=3) = 0
>> ID: ea1c (Type=7) =
>> ID: ea1c (Type=7) =
>> ID: ea1d (Type=9) =
>> ID: 5023 (Type=3) = 6
>> ID: 502d (Type=5) =
>> ID: 502e (Type=5) =
>> ID: 5030 (Type=3) = 2
>> ID: 201 (Type=4) = 6480
>> ID: 202 (Type=4) = 4387
>> ID: 501b (Type=1) =
>> ID: 5090 (Type=3) = 1
>> ID: 5091 (Type=3) = 4

 

According to the excellent Microsoft Photo Info tool (though even this tool ignore the rotation flag), I have all the possible title fields set:

According to the Windows file properties, they're all set:

Finally, Michael Valasek's excellent EXIF reader tool can't find the tags either:

What does one need to do to read image caption/title information in .NET?  If anyone's curious, here's a link to the original image (1.2MB).  It's driving me crazy!




Feedback

# re: What's up with EXIF properties in .NET?

I'm working on the same thing. If sometimes you can find the keywords in tag 0x9C9E, it also appears sometimes in tag 0x501B, but there seems to be a much more complex data structure in it... I'm currently working on it, let me know if you're interested in further information.
picrap (at) gmail (dot) com
8/19/2007 2:07 PM | picrap

# re: What's up with EXIF properties in .NET?

Forget about my previous comment.
.NET 3.0 offers a simple (and apparently unified) way to get access to main information:

using (Stream stream = File.OpenRead(@"mypic.jpg"))
{
BitmapDecoder decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.Default);
BitmapFrame frame = decoder.Frames[0];
BitmapMetadata metaData = (BitmapMetadata) frame.Metadata;
// you have here access to common propoerties, such as Keywords, Comment, etc.
}
8/19/2007 5:47 PM | picrap

# re: What's up with EXIF properties in .NET?

The reason why it doesn't show this information is, that they are not Exif tags. The data are saved in the IPTC header and I assume .NET read only Exif properties.

Additionally I don't recommend to modify the Exif-data using GDI+ or any other program which is written by Microsoft, because this will destroy the maker notes, which are part of the Exif data.

I recommend to use a program like PhotoME (http://www.photome.de) or ExifTool (http://www.sno.phy.queensu.ca/~phil/exiftool/) to read and modify the Exif data without any destruction of the Metadata. 10/5/2007 3:18 AM | Thomas

# re: What's up with EXIF properties in .NET?

Thomas,
Thanks! You are right. They aren't all actually EXIF. There are IPTC, XMP, and other types of tags. .NET just does a bad job of dealing with them, and as you point out, it's a destructive write even when you can find/update what you want. .NET 3.0 does a better job of it, but it still doesn't handle it all properly. I love ExifTool, and PhotoME looks like a good one that I hadn't seen, but neither offer an .NET API. That's the bottom line. I don't want to call out to a shell process to manage metadata -- I just want it to work! 10/5/2007 10:40 AM | Arian

# re: What's up with EXIF properties in .NET?

Hello,
I want to read Exif Meta Data in .NET 2.0 I had done it with Image class but it takes lots of time to load the whole Image is there any option by which we should not load Image and get the properties...

Please email gurnani.sunny@gmail.com

Thanks 10/10/2007 12:32 PM | Sunny

# re: What's up with EXIF properties in .NET?

Not that I know of. If you want to read image properties without reading the entire image, you'll need to open the file as a byte stream, read the offset tables and jump to the property block of interest. There are probably libraries out there to do this. 10/10/2007 12:44 PM | Arian



Comments have been closed on this topic.