Trying to extract geotagged image data using java

237 views Asked by At

Hi I'm trying to extract geotagged image data using java. But it's not working as expected. I added my code below.

try {

        File file = new File("/home/xxx/Downloads/accidentImage");

        for (File filelist : file.listFiles()) {

        Metadata metadata = ImageMetadataReader.readMetadata(filelist);
        ExifSubIFDDirectory directory
                    = metadata.getDirectory(ExifSubIFDDirectory.class);
            Date date
                    = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
            GpsDirectory gpsDirectory = metadata.getDirectory(GpsDirectory.class);
            GeoLocation geoLocation = gpsDirectory.getGeoLocation();
            double lat = geoLocation.getLatitude();
            double lon = geoLocation.getLongitude();

        }

    } catch (Exception e) {
        e.printStackTrace();
    }
0

There are 0 answers