The MetadataExtractor library has been available for Java since 2002 and is now fully supported for .NET. It supports Exif GPS data from JPEG files, as well as tons of other types and types of metadata files.
The following are examples from iPhone 4 , iPhone 5, and iPhone 6 .
Available via NuGet:
PM> Install-Package MetadataExtractor
Then, to access the GPS location, use the following code:
var directories = ImageMetadataReader.ReadMetadata(jpegFilePath); var gps = directories.OfType<GpsDirectory>().FirstOrDefault(); var location = gps?.GetGeoLocation(); if (location != null) Console.WriteLine("Lat {0} Lng {1}", location.Latitude, location.Longitude);
Or print each detected value:
var lines = from directory in directories from tag in directory.Tags select $"{directory.Name}: {tag.TagName} = {tag.Description}"; foreach (var line in lines) Console.WriteLine(line);
Drew noakes
source share