Click here to Skip to main content
12,889,951 members (43,986 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 2 Jul 2007

Retrieving EXIF information of an image in .NET 3.0

, 2 Jul 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
How to retrieve EXIF information of an image in .NET 3.0.

Screenshot - Article_Image.jpg


When we talk about digital photography, one of the things which comes to mind is EXIF info. What is it? EXIF is the short for "Exchangeable Image File". This is a standard for storing interchangeable information in digital photography image files using JPEG compression. Most of the new digital cameras use the EXIF annotation, and store information on the image such as shutter speed, exposure, compensation, F number, metering system, ISO number, Date Time etc. This piece of code explains how to retrieve the EXIF information from an image using .NET 3.0.

Using the code

To use the code, you should have the following items installed on your machine:

  • .NET Framework 3.0
  • WPF Patch release for Visual Studio 2005

Using the code is pretty simple, and can be downloaded from above. In the code, the constructor of class ExifMetaInfo accepts the URI of an image as a parameter, and creates an object of type BitmapFrame (BitmapFrame is a new class library available under "System.Windows.Media.Imaging" of .NET 3.0). Once the BitmapFrame object is created, we can get the meta-data information of the image using the MetaData property of BitmapFrame. We can type cast the MetaData property to the BitmapMetadata class, which is again a new class in .NET 3.0 under "System.Windows.Media.Imaging". Now, it's a matter of passing the right parameters to the "BitmapMetadata" object to get the EXIF information. Following is a list of parameters which we may pass to get the appropriate EXIF information:


.....and many more.

The section below shows a snap of the constructor of the ExifMetaInfo class, which accepts a URI as a parameter and creates an object of type BitmapFrame:

public ExifMetaInfo(Uri imageUri)
    BitmapFrame bFrame = BitmapFrame.Create(imageUri, 
    _metaInfo = (BitmapMetadata)bFrame.Metadata;

Once we are done with the creation of the object, the next thing to do is to fetch the values. In the given class, all the EXIF info is being retrieved through properties. The code below shows the retrieval of the Width property of the image:

public uint? Width
        object obj = GetMetaInfo("/app1/ifd/exif/subifd:{uint=40962}");
        if (obj == null)
            return null;
            if (obj.GetType() == typeof(UInt32))
                return (uint)obj;
                return Convert.ToUInt32(obj);

private object GetMetaInfo(string infoQuery)
    if (_metaInfo.ContainsQuery(infoQuery))
        return _metaInfo.GetQuery(infoQuery);
        return null;

Points of interest

Please note that all JPG images may not have EXIF info available. You may modify the code of the ExifMetaInfo class to give a user friendly message when no information is available.


Nothing available at present.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

Generalgps information Pin
cookie_biscuit28-Mar-09 15:17
membercookie_biscuit28-Mar-09 15:17 
GeneralRe: gps information Pin
Felipe Ceotto17-Apr-09 0:44
memberFelipe Ceotto17-Apr-09 0:44 
Generaledit the exif information using .net 2.0 Pin
nallamani198317-Mar-09 21:32
membernallamani198317-Mar-09 21:32 
GeneralASP.NET 3.0 Pin
RoelAlblas12-Jul-08 4:45
memberRoelAlblas12-Jul-08 4:45 
AnswerRe: ASP.NET 3.0 Pin
uttam1914-Nov-08 23:54
memberuttam1914-Nov-08 23:54 
GeneralMetadata 272 may contain string[] Pin
CodeChampion22-Apr-08 4:18
memberCodeChampion22-Apr-08 4:18 
QuestionExif GetQuery strings Pin
GreenKnight12-Sep-07 3:51
memberGreenKnight12-Sep-07 3:51 
GeneralRe: Exif GetQuery strings Pin
FaulstiR7-Dec-07 17:46
memberFaulstiR7-Dec-07 17:46 
AnswerRe: Exif GetQuery strings Pin
FaulstiR7-Dec-07 18:07
memberFaulstiR7-Dec-07 18:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 2 Jul 2007
Article Copyright 2007 by Puru Adhikari
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid