I realize this answer does not address .NET framework v2, but I thought it was worth documenting for those of you who are using .NET 3.5 or higher. This might also work in 3.0 but I have not tested it there.
The following function call will return the keywords embedded in a JPEG image:
private string[] GetKeywords(string filespec)
{
BitmapDecoder decoder = new JpegBitmapDecoder(new FileStream(filespec, FileMode.Open), BitmapCreateOptions.None, BitmapCacheOption.None);
BitmapMetadata meta = (BitmapMetadata)decoder.Frames[0].Metadata;
return meta.Keywords.ToArray<string>();
}
The BitmapDecoder and BitmapMetadata class are contained in an assembly that is normally used in WPF, so you'll need to reference the following assemblies to use those classes:
- PresentationCore
- WindowsBase
I am successfully using this approach in a WinForm app, but I suspect it could be adapted for other application types. Also, you can see that the abstract "BitmapDecoder" class in this example is assigned a JpegBitmapDecoder instance, but you could get an instance of another decoder for your image type (TIFF, GIF, PNG, BMP, and WMP are also supported).