Search code examples
fluttergeolocation

Is possible to get Image GPS location coordinates from the Image?


I'm building a Flutter App where the user can post a photo and it's location. The use can both get a picture from the camera or from the library.

If the user take a picture from camera I can use the GPS location of the device to set the picture's location. I'm trying to get the GSP location of the pictures based on its metadata, but, I didn't found a way to do it yet.

Is possible to do it? How the best way?

Edit: I put "GPS" in the question to make it clear. I'm trying to discover the physical position where the picture was taken. I also added "Flutter" to the question to make it clear that I'm facing the problem of solving this problem in a Flutter App.


Solution

  • The geolocation metadata is stored as Exif tags provided the image is a JPEG or a RAW image file. In Android this is done through the ExifInterface class.

    The tags are TAG_GPS_LATITUDE and TAG_GPS_LONGITUDE: https://developer.android.com/reference/android/media/ExifInterface.html

    Please note the coordinates need to be expressed in the rational format: degrees, minutes and seconds, as dd/1,mm/1,ss/1.