Click or drag to resize

ExifParser Class

Parses EXIF data from JPEG or TIFF images into a collection of EXIF tags.
Inheritance Hierarchy

Namespace:  Atalasoft.Imaging.Metadata
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: (.NET 4.5.2, x86)
public class ExifParser

The ExifParser type exposes the following members.

Public methodExifParser
Initializes a new instance of ExifParser.
Public propertyFormatTags Obsolete.
Public propertyThumbnailCallback Obsolete.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnError
Raises the [E:Error] event.
Public methodCode exampleParseFromByteArray
Parses a byte array of EXIF data.
Public methodCode exampleParseFromImage(Stream)
Parses EXIF data from a JPEG or TIFF image file stream.
Public methodCode exampleParseFromImage(String)
Parses EXIF data from a JPEG or TIFF image file.
Public methodCode exampleParseFromImage(Stream, Int32)
Parses EXIF data from an image file stream, specifying the frame index of a multipage TIFF.
Public methodCode exampleParseFromImage(String, Int32)
Parses EXIF data from an image file, specifying the frame index of a multipage TIFF.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public eventCodecError
This event is used by the ExifParser object to report errors that occur when parsing an image.

EXIF (Exchangeable Image File Format) is a standard for storing interchange information in image files, in particular JPEG images. This metadata is commonly used in digital camera images to store information specific to digital photography such as shutter speed, date taken, aperture, GPS information, and other information depending on the make of the camera.


This example demonstrates how to retreive EXIF tags from a JPEG image.

[New Example] (C#)
ExifTextParser exifParser = new ExifTextParser();
ExifTextCollection exifTags = exifParser.Parse("myimage.jpg");
[New Example] (Visual Basic)
Dim exifParser As ExifTextParser = New ExifTextParser()
Dim exifTags As ExifTextCollection = exifParser.Parse("myimage.jpg")

This example shows how to retrieve EXIF data from an image, then save it back to a new image.

[New Example] (C#)
//get EXIF Tags
ExifParser exifParse = new ExifParser();
ExifCollection exifTags = exifParse.ParseFromImage(@"c\in.jpg");
//get JPEG Markers
JpegMarkerCollection appMarkersIn = new JpegMarkerCollection(@"c\in.jpg");
//read image
Workspace myWorkspace = new Workspace();
//get the DataTime Tag from the image and display the value
if (exifTags != null)
    ExifTag tag = exifTags.LookupTag("DateTime");
    if (tag != null)
        MessageBox.Show("This photo was taken on " + tag.Data.ToString());
JpegEncoder jpeg = new JpegEncoder(75);
//only write EXIF Tags back to the image (APP1)
JpegMarkerCollection appMarkersOut = new JpegMarkerCollection();
foreach (JpegMarker mk in appMarkersIn)
    if (mk.Type == JpegMarkerTypes.MarkerApp1)
jpeg.AppMarkers = appMarkersOut;
myWorkspace.Save("c:\\out.jpg", jpeg);
[New Example] (Visual Basic)
'get EXIF Tags
Dim exifParse As ExifParser = New ExifParser() 
Dim exifTags As ExifCollection = exifParse.ParseFromImage("c\in.jpg") 
'get JPEG Markers
Dim appMarkersIn As JpegMarkerCollection = New JpegMarkerCollection("c:\in.jpg") 
'read image
Dim myWorkspace As Workspace =  New Workspace() 
'get the DataTime Tag from the image and display the value
If Not exifTags Is Nothing Then
    Dim tag As ExifTag =  exifTags.LookupTag("DateTime") 
    If Not tag Is Nothing Then
        MessageBox.Show("This photo was taken on " & tag.Data.ToString())
    End If
End If
Dim jpeg As JpegEncoder =  New JpegEncoder(75) 
'only write EXIF Tags back to the image (APP1)
Dim appMarkersOut As JpegMarkerCollection = New JpegMarkerCollection() 
Dim mk As JpegMarker
For Each mk In appMarkersIn
    If mk.Type = JpegMarkerTypes.MarkerApp1 Then
    End If
jpeg.AppMarkers = appMarkersOut
myWorkspace.Save("c:\out.jpg", jpeg)
See Also


EXIF Description
Metadata Overview