This document is archived and information here might be outdated.  Recommended version.


How to access JPEG EXIF tags (ArcObjects .NET 10.4 SDK)

How to access JPEG EXIF tags


Accessing JPEG EXIF tags

Some Joint Photographic Experts Group (JPEG) images have Exchangeable Image File (EXIF) format tags stored in the header. To access EXIF information, see the following code example:
[C#]
public static void JPEG_EXIFtag(IRasterDataset exifDataset)
{
    //exifDataset represents a raster dataset opened from a JPEG file that has EXIF tags.
    IDataset dataset=(IDataset)exifDataset;
    //Get the EXIF tags and the associated values.
    IPropertySet propertySet=dataset.PropertySet;
    System.Object tag_names;
    System.Object tag_values;
    propertySet.GetAllProperties(out tag_names, out tag_values);
    string[] stringNames=(string[])tag_names;
    object[] stringValues=(object[])tag_values;
    for (int i=0; i < stringNames.Length - 1; i++)
    {
        System.Console.WriteLine(stringNames[i]);
        System.Console.WriteLine(stringValues[i]);
    }
}
[VB.NET]
Public Shared Sub JPEG_EXIFtag(ByVal exifDataset As IRasterDataset)
'exifDataset represents a raster dataset opened from a JPEG file that has EXIF tags.
Dim dataset As IDataset=CType(exifDataset, IDataset)

'Get the EXIF tags and the associated values.
Dim propertySet As IPropertySet=dataset.PropertySet
Dim tag_names As System.Object
Dim tag_values As System.Object

propertySet.GetAllProperties(tag_names, tag_values)
    Dim stringNames() As String=CType(tag_names, String())
    Dim stringValues() As Object=CType(tag_values, Object())
    
    Dim i As Integer
    For i=0 To stringNames.Length -1 - 1 Step i + 1
        System.Console.WriteLine(stringNames(i))
        System.Console.WriteLine(stringValues(i))
    Next
End Sub






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
Engine Developer Kit Engine