

Geolocation photo reader code#
Thanks to extension methods I created before the code in controller action is clean and minimal.Īnd here’s the end result. Using ( var reader = new ExifReader( "my-photo.jpg")) public class PhotoCoordinatesModelĪnd here is my demo controller action that reads EXIF data. This model must carry coordinates – if available – and also error information if something went wrong when reading EXIF data. To get data to browser we need a model for it. These methods are actually simple but it’s the good task for students to work these out. Return coordinates + coordinates / 60f + coordinates / 3600f Private static double ToDoubleCoordinates( double coordinates) If (reader.GetTagValue(type, out double coordinates)) Private static double? GetCoordinate( this ExifReader reader, ExifTags type) Return reader.GetCoordinate( ExifTags.GPSLongitude) Public static double? GetLongitude( this ExifReader reader) Return reader.GetCoordinate( ExifTags.GPSLatitude) Public static double? GetLatitude( this ExifReader reader) LatitudeReal = latitude + latitude / 60 + latitude / 3600īased on this I developed some extension methods to make reading of coordinates easier. Latitude can be transformed to real number using the following calculation: First number is degree, second one is minutes and third one seconds. Getting components of coordinates to real number is easy. Maps used on web pages usually need coordinates as real numbers. This is not shortcut done by library developer but this is how devices save coordinates.įor me this information was enough to get done with what I was up to. Getting GPS coordinates is a little tricky as coordinates are given back as an array of doubles containing degree, minute and second. Some libraries got extremely slow with photos bigger than 3 MB but ExifLib.Standard seems survive well. Reader.GetTagValue( ExifTags.DateTimeDigitized, out DateTime photoDate) īest thing about ExifLib.Standard – it works reasonably fast also with bigger photos (I tried few ones that are ~7 MB). Reader.GetTagValue( ExifTags.DigitalZoomRatio, out double brightness) using ( var reader = new ExifReader( "my-image.jpg"))
Geolocation photo reader how to#
Here is the sample how to read some EXIF fields. For this demo I decided to use some library that deals only with EXIF data, My choice was NuGet package called ’s simple to use, kind of primitive and basic, but it works well and does its job. There are some libraries available for ASP.NET Core for reading EXIF data from photos. It’s great but be aware – not all people may use this information in good purposes. Most of modern devices used to take photos save meta information in EXIF format to photos. Wikipedia defines EXIF (Exchangeable image file format) as a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras (including smartphones), scanners and other systems handling image and sound files recorded by digital cameras. This blog post describes my experiment on getting GPS coordinates from EXIF data in ASP.NET Core application. I took my favorite photo of beer kiosk in Krakow and displayed location of this kiosk on map. Follow the links and check the images you find on PixelPeeper.During one of my ASP.NET Core classes I made demo about how to read GPS coordinates from photo and display location on a map. Next, go to Google Image Search, click on "Search by Image" icon and upload the file.Ĭlick on "Search by Image" and Google will show you different websites where this (or similar) photo is published.
Geolocation photo reader download#
When you`'re on instagram (website, not the app), download the photo (the link is hidden in the source code), or take a screenshot of it and save it on your desktop. Use Google Image SearchĪnother trick is to use Google Image Search to find different versions of the photo you want to check. For example: if the author has a website, there‘s a chance they upload the same photos there as well - and you have a much bigger chance finding original photos with metadata on their website. So, there‘s no way to get EXIF metadata directly from Instagram, but there are a few tricks and workarounds you can try. If they didn‘t remove it, you can only imagine what stalkers could use it for. There are also privacy concerns: photos taken on phones can contain the exact location they were taken at. Instagram strips it to save up on bandwidth (metadata makes files bigger). Photos downloaded directly from Instagram won‘t work with PixelPeeper, because they don‘t contain EXIF data. PixelPeeper can reverse-engineer Lightroom edits from photos, but it needs JPGs with metadata (EXIF for camera settings and XMP for Lightroom edits). How to Get Metadata for Instagram Photos (EXIF & XMP)?
