简体   繁体   中英

Read metadata with ExifTool

I'm trying to read illustrator file metadata value by using Exiftool. I tried as per below.

File[] images = new File("filepath").listFiles();
ExifTool tool = new ExifTool(Feature.STAY_OPEN);
for(File f : images) {
    if (f.toString().contains(".ai"))
    {
        System.out.println("test "+tool.getImageMeta(f, Tag.DATE_TIME_ORIGINAL));
    }
}
tool.close(); 

Above code not printing any value. I even tried this.

public static final File[] IMAGES = new File("filepath").listFiles();
ExifTool tool = new ExifTool(Feature.STAY_OPEN);
for (File f : IMAGES) {
System.out.println("\n[" + f.getName() + "]");
System.out.println(tool.getImageMeta(f, Format.NUMERIC,
Tag.values()));
}

Which only prints {IMAGE_HEIGHT=2245, IMAGE_WIDTH=5393} . How do I call metadata values using Exiftool. Any advices and references links are highly appreciated.

For the given API, it either;

1-does not contain the tag you are looking for

2-the file itself might not have that tag filled

3-you might want to recreate your own using a more general tag command when calling exiftool.exe

Look in the source code and find the enum containing all the tags available to the API, that'll show you what you're restricted to. But yeah, you might want to consider making your own class similar to the one you're using. I'm in the midst of doing the same. That way you can store the tags in perhaps a set or HashMap instead of an enum and therefore be much less limited in tag choice. Then, all you have to do is write the commands for the tags you want to the process's OutputStream and then read the results from the InputStream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM