Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Date Taken of an image

Tags:

java

image

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

like image 677
Jatin Avatar asked Nov 26 '12 06:11

Jatin


People also ask

Can you take the date off a picture?

Date Stamp Removal Using The Crop Tool Cropping is the easiest and fastest way to get rid of unwanted objects in photos. You don't even need Photoshop for this, as most standard photo editing tools in your phone or computer will come with a cropping option.


1 Answers

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.

like image 129
Jatin Avatar answered Oct 23 '22 07:10

Jatin