Contemporary digital cameras imprint metadata, or information about the photo, within the photo itself. This blog addresses what information is commonly available, the data extracted from a specific JPEG image, and how to extract it using the C# programming language.
Digital Photograph Metadata
Several types of data can be extracted from an image such as property information and compositional elements.
Below is a standard JPEG formatted image taken from a Nikon 3100 digital camera.
The following table shows what image property information is commonly available and present in the above image. The table includes the following information:
• Item ID in Decimal Format
• Item ID in Hexagonal Format
• Type ID
The complete list of Type IDs are included in the following link:
https://msdn.microsoft.com/en-us/library/system.drawing.imaging.propertyitem.type(v=vs.110).aspx
• Data Type
The following is a list of data types that can be returned:
– Byte Array
– String
– Unsigned Int32 Array
– Unsigned Int64 Array
– Signed Int32 Array
– Signed Int64 Array
– Rational (Array of Pairs of Unsigned Int64)
– SRational (Array of Pairs of Signed Int64)
• Property
The complete list of properties that can be in an image is included in the following links.
– https://msdn.microsoft.com/de-de/library/ms534416.aspx
– http://exif-utils.googlecode.com/svn/trunk/ExifUtils/ExifUtils/Exif/ExifTag.cs
• Value
The following table shows what compositional elements are available for an image, and their values for the image above.
Extracting the Metadata using C#
Extracting photo meta data is easy using C#. The following function is an example of how to extract meta data from a photograph.
This method extracts the Picture Taken Date from the photograph passed to the method as a Bitmap object.
From the above table the id 36867 is the item id for the Date Time of the photo.
This method could easily be abstracted to return any property as a string using the following method signature:
private static string GetDataFromBitmap(Bitmap bitmap, int typeId)
This blog discussed the information that is commonly available in a digital photograph, the data extracted from a specific JPEG image, and how to extract the data it using the C# programming language.