I want to find the "Date taken" of the image, not the "date changed" or "date created." Although I found some links to stackoverflow, but no one was able to get it. Image format: tiff and RAW.
Using javax.imageio , I wrote the program below, but it doesn't print anything. That means 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 basic Java libraries, there is a method for accessing “dates” rather than “date created” or “date changed”. In addition, data taken information is available, as I can see from the image properties in the OS
EDIT: It turns out that the readers iterator has nothing to do with it. those. size 0. This only happens for tiff and raw images. Works well with jpeg
source share