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.


Warning: count(): Parameter must be an array or an object that implements Countable in /nfs/c07/h02/mnt/110221/domains/markarteaga.com/html/wp-includes/class-wp-comment-query.php on line 405

2 thoughts on “Extracting EXIF Tags using Compact Framework”

  1. 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…

  2. 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

Leave a Reply