Extracting EXIF Tags using Compact Framework#

We got a request from a customer on how to extract EXIF Tags from an image taken with a camera using .NET Compact Framework and the Smart Device Framework

The OpenNETCF.Drawing.Imaging namespace in the Smart Device Framework does provide this data but if you are not familiar with the namespace it may be a little tricky getting the information.

Basically what you have to do is get an IImageDecoder object using the ImagingFactory class.  From there call ImageUtils.GetAllProperties(decoder) which returns an array of ImageProperty[] objects.

Here is the bulk of the code:

StreamOnFile st = new StreamOnFile(openFileDialog1.FileName);
IImageDecoder decoder = null;
ImagingFactory factory = new ImagingFactoryClass();
factory.CreateImageDecoder(st, DecoderInitFlag.DecoderInitFlagNone, out decoder);
ImageProperty[] props = ImageUtils.GetAllProperties(decoder);

foreach (ImageProperty prop in props)
{
   //For Specific tags see ImageTag enum. 
   textBox1.Text = prop.Id.ToString() + ": " + GetValue(prop) + "\r\n" + textBox1.Text;
}
decoder.TerminateDecoder();

And the output:

Download the sample application here.


Thursday, February 01, 2007 12:14:17 PM (Eastern Standard Time, UTC-05:00) #    Comments [2]  | 

 

All content © 2010, Mark Arteaga
Related Sites
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts