javametadata-extractor

Image metadata from iPhone 7 front camera doesn't give the created date


I'm trying to get the created date value from an Image taken from iPhone 7 (front) using metadata-extractor. I can't find the created date. This is the code snippet.

File file1 = new File ("/Work/Image/Metadata/IMG_0644.jpg");
Metadata metadata = ImageMetadataReader.readMetadata(file1);
ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
Date date = directory2.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
System.out.println(date);

<dependency>
  <groupId>com.drewnoakes</groupId>
  <artifactId>metadata-extractor</artifactId>
  <version>2.11.0</version>
</dependency>

Date is always printed as null. Am I missing something? Thanks!


Solution

  • There are several tags that could contain the date time. I suggest you print out all the tags, then find out which directories/tags work for you.

    for (Directory directory : metadata.getDirectories()) {
        for (Tag tag : directory.getTags()) {
            System.out.println(tag);
        }
    }