0

I'm developping an images Manager program in Java. I would like to retrieve the notations, and eventually other informations like date or key words available in Windows explorer. Is there any way to retrieve those informations?

AxelF
  • 109
  • 3
  • 15
  • Maybe a duplicate of http://stackoverflow.com/questions/3851665/java-library-for-reading-and-writing-iptc-metadata-to-jpeg-and-tiff ? – Michael Zilbermann Oct 09 '12 at 10:56
  • Thanks didn't knew that lib! But it seems it doesn't know the rating tag. When i get all tags of the jpg, it return the rating like that: `[Exif IFD0] Unknown tag (0x4746) - 3`. But there isn't any rating tag in the ExifIDF0Directory. – AxelF Oct 09 '12 at 13:15

1 Answers1

0

Ok I think I found a solution:

I'm using the tagDescriptor and the tagType.

First i need to get this tagType :

File pic = new File("C:/myPicture.jpg"); 
Metadata metadata = ImageMetadataReader.readMetadata(pic);
        for (Directory directory : metadata.getDirectories()) {
            for (Tag tag : directory.getTags()) {
                System.out.println(tag + " - " +tag.getTagType());
            }
        }

For the rating, it returned:

[Exif IFD0] Unknown tag (0x4746) - 3 - 18246

Now that i know the tagType:

ExifIFD0Directory exifDirectory = metadata.getDirectory(ExifIFD0Directory.class);
ExifIFD0Descriptor descriptor = new ExifIFD0Descriptor(exifDirectory);
TagDescriptor td = new TagDescriptor(exifDirectory) {};
int rating = Integer.parseInt(td.getDescription(18246));

Feel free to comment if there is a better solution

AxelF
  • 109
  • 3
  • 15