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]  | 

 

Wednesday, January 02, 2008 2:26:16 PM (Eastern Standard Time, UTC-05:00)
Mark, this is some great code to get the Exif tags from jpgs. Is there a way to modify the decoder to also get the XMP tags? A lot of camera information is put in the XMP and not in the Exif tags.
Ed...
Thursday, January 24, 2008 6:50:41 PM (Eastern Standard Time, UTC-05:00)
Hi,

Nice example. Thanks. Is there a way to change the value of the ImageProperty (EXIF Tags)? Also, is there a way to create & insert new Image Property into the image (as in add a new EXIF tag to the image)?
Thanks!

-Sheila
Comments are closed.
All content © 2008, Mark Arteaga
On this page
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