Android how to access location data in jpg

I am creating an Android application that includes the ability to display images on a map.

How can I extract location data from a .jpg file (if there is location data)?

Thanks a lot, Todd.

+4
source share
2 answers

There is a good tutorial on how to access exif data (which includes the GPS information you need) from jpg, which can help you:
http://android-coding.blogspot.com/2011/10/read-exif-of-jpg-file-using.html

The corresponding class is described in official documents:
http://developer.android.com/reference/android/media/ExifInterface.html

You can also find useful mail (convert GPS information):
http://android-coding.blogspot.com/2011/10/convert-gps-tag-of-exifinterface-to.html

+9
source

Here is how I did it:

try { final ExifInterface exifInterface = new ExifInterface(imagePath); float[] latLong = new float[2]; if (exifInterface.getLatLong(latLong)) { // Do stuff with lat / long... } } catch (IOException e) { logger.info("Couldn't read exif info: " + e.getLocalizedMessage()); } 
0
source

Source: https://habr.com/ru/post/1416552/


All Articles