Click or drag to resize

ExifParser Class

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

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

The ExifParser type exposes the following members.

Constructors
  NameDescription
Public methodExifParser
Initializes a new instance of ExifParser.
Top
Properties
  NameDescription
Public propertyFormatTags Obsolete.
Deprecated
Public propertyThumbnailCallback Obsolete.
Deprecated
Top
Methods
  NameDescription
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.)
Top
Events
  NameDescription
Public eventCodecError
This event is used by the ExifParser object to report errors that occur when parsing an image.
Top
Remarks

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.

Examples

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();
myWorkspace.Open(@"c\in.jpg");
//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)
        appMarkersOut.Add(mk);
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() 
myWorkspace.Open("c:\in.jpg")
'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
        appMarkersOut.Add(mk)
    End If
Next
jpeg.AppMarkers = appMarkersOut
myWorkspace.Save("c:\out.jpg", jpeg)
See Also

Reference

EXIF Description
Metadata Overview