Read and Extract EXIF Metadata from Images in C#

GdPicture offers an image parsing mechanism that allows direct access to image properties such as metadata, ICC profiles, and embedded thumbnails without decoding pixels. This feature is particularly useful if you need to quickly extract document information without editing and rendering it on the screen.

The code below shows how to quickly extract EXIF metadata from any kind of image supported by the toolkit:

// We assume GdPicture has been correctly installed and unlocked.
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
// Loading the image in direct access mode.
int ImageID = oGdPictureImaging.CreateGdPictureImageFromFile("image.JPG", false, true);
if (oGdPictureImaging.GetStat() == GdPictureStatus.OK)
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    int exifTagsCount = oGdPictureImaging.TagCount(ImageID);
    if (exifTagsCount != 0)
    {
        // Handling EXIF tags.
        sb.Append("EXIF tags:\n-----------\n");
        for (int i = 1; i <= exifTagsCount; i++)
        {
            string tagName = oGdPictureImaging.TagGetName(ImageID, i);
            string tagFormattedValue = oGdPictureImaging.TagGetValueString(ImageID, i);
            sb.Append(tagName + ": " + tagFormattedValue + "\n");
        }
    }
    oGdPictureImaging.ReleaseGdPictureImage(ImageID);
    MessageBox.Show(sb.ToString(), "Metadata Example", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
    MessageBox.Show("The image can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), "Metadata Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
oGdPictureImaging.Dispose();
'We assume GdPicture has been correctly installed and unlocked.
Dim oGdPictureImaging As New GdPictureImaging()
'Loading the image in direct access mode.
Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("image.JPG", False, True)
If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then
    Dim sb As New System.Text.StringBuilder()
    Dim exifTagsCount As Integer = oGdPictureImaging.TagCount(ImageID)
    If exifTagsCount <> 0 Then
        'Handling EXIF tags.
        sb.Append("EXIF tags:" & vbCrLf & "-----------" & vbCrLf)
        For i As Integer = 1 To exifTagsCount
            Dim tagName As String = oGdPictureImaging.TagGetName(ImageID, i)
            Dim tagFormattedValue As String = oGdPictureImaging.TagGetValueString(ImageID, i)
            sb.Append(tagName + ": " + tagFormattedValue + vbCrLf)
        Next
    End If
    oGdPictureImaging.ReleaseGdPictureImage(ImageID)
    MessageBox.Show(sb.ToString(), "Metadata Example", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
    MessageBox.Show("The image can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), "Metadata Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
oGdPictureImaging.Dispose()

The result of this code is shown below.

EXIF tags