public static GeoLocation getMetadata(String filename) {
GeoLocation gl = null;
try {
File file = new File(filename);
Metadata metadata = ImageMetadataReader.readMetadata(file);
for (Directory directory : metadata.getDirectories()) {
if (directory instanceof GpsDirectory) {
GpsDirectory gpsd = (GpsDirectory)directory;
gl = gpsd.getGeoLocation();
}
}
} catch (ImageProcessingException | IOException ex) {
Logger.getLogger(ImageHelper.class.getName()).log(Level.SEVERE, null, ex);
}
return gl;
}
Very simple.
The example uses metadata extractor in Java.
http://www.drewnoakes.com/code/exif/