Reputation: 31724
I want to find the "Date Taken" of an image and not "date modified" or "date created". Though I have found some links on stackoverflow, but none could retrieve it. The image format is: tiff and RAW.
Using javax.imageio
, I wrote the below program, but it prints nothing. Which means there is no reader
available
File file = new File( fileName );
ImageInputStream iis = ImageIO.createImageInputStream(file);
Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
if (readers.hasNext()) {
// pick the first available ImageReader
ImageReader reader = readers.next();
// attach source to the reader
reader.setInput(iis, true);
// read metadata of first image
IIOMetadata metadata = reader.getImageMetadata(0);
String[] names = metadata.getMetadataFormatNames();
int length = names.length;
for (int i = 0; i < length; i++) {
System.out.println( "Format name: " + names[ i ] );
displayMetadata(metadata.getAsTree(names[i]));
}
}
Using the core java libraries, is there a method to access "date taken" and not "date created" or "date modified".
Further the data taken
info is available as I can see that from image properties in OS
EDIT: It turns out that readers
iterator has nothing with it. i.e.e size 0. It is only happening for tiff and raw images. Works well with jpeg
Upvotes: 9
Views: 12116
Reputation: 31724
I could not find any solution using java core libraries. Found a library called metadata-extractor which does the job.
More info can be found here.
Upvotes: 11