Reputation: 31
I need a c# script for unity that can read the EXIF lat/long data from a photo. i would like to place a posTransform at that location. not sure if this is possible within Unity. i would like to load my images into unity and have a script read the EXIF: 1-GPS lat/long, 2-rotation, 3-timestamp from photographs. i haven't found any info that says this can be done within unity, however, i've read about exiflib github project and other ways outside of unity.
THANKS in advance for help
Upvotes: 1
Views: 2102
Reputation: 21
The answer from Drew Noakes doesn't work because it has dependencies on .NET that Unity doesn't support.
In my opinion, the best option right now, after a few days of research, is this project:
https://www.codeproject.com/Articles/5251929/CompactExifLib-Access-to-EXIF-Tags-in-JPEG-TIFF-an
This is a simple one-file project that you can drag in your unity project and that has no external dependencies. And it can read and update EXIF tags for JPG, PNG and TIFF files.
Upvotes: 1
Reputation: 310802
I maintain a project for extracting metadata from images that will give you what you need.
https://github.com/drewnoakes/metadata-extractor-dotnet
The library supports .NET 3.5 so should work under Unity, though I haven't tested it before.
With it, you would write:
var directories = ImageMetadataReader.ReadMetadata(filePath);
var gpsDirectory = directories.OfType<GpsDirectory>().FirstOrDefault();
if (gpsDirectory != null)
{
var location = gpsDirectory.GetGeoLocation();
Console.WriteLine($"Photo was taken at {location.Latitude},{location.Longitude}");
}
Upvotes: 2